package main import ( "github.com/terorie/od-database-crawler/fasturl" "testing" ) func TestParseDirNginx(t *testing.T) { var u fasturl.URL err := u.Parse("https://the-eye.eu/public/") if err != nil { t.Fatal("Failed to parse URL", err) } links, err := ParseDir([]byte(nginxListing), &u) if err != nil { t.Fatal("Failed to extract links", err) } if len(links) != len(nginxLinks) { t.Fatalf("Expected %d links, got %d", len(nginxLinks), len(links)) } for i := 0; i < len(links); i++ { gotLink := links[i].String() expLink := nginxLinks[i] if gotLink != expLink { t.Errorf(`Expected "%s" got "%s"`, expLink, gotLink) } } } var nginxLinks = []string { "https://the-eye.eu/public/AppleArchive/", "https://the-eye.eu/public/AudioBooks/", "https://the-eye.eu/public/Books/", "https://the-eye.eu/public/Comics/", "https://the-eye.eu/public/Games/", "https://the-eye.eu/public/Icons/", "https://the-eye.eu/public/Images/", "https://the-eye.eu/public/JFK_Files/", "https://the-eye.eu/public/MSDN/", "https://the-eye.eu/public/Music/", "https://the-eye.eu/public/Operating%20Systems/", "https://the-eye.eu/public/Posters/", "https://the-eye.eu/public/Psychedelics/", "https://the-eye.eu/public/Psychoactives/", "https://the-eye.eu/public/Radio/", "https://the-eye.eu/public/Random/", "https://the-eye.eu/public/Site-Dumps/", "https://the-eye.eu/public/Software/", "https://the-eye.eu/public/Strategic%20Intelligence%20Network/", "https://the-eye.eu/public/WorldTracker.org/", "https://the-eye.eu/public/concen.org/", "https://the-eye.eu/public/freenrg.info/", "https://the-eye.eu/public/murdercube.com/", "https://the-eye.eu/public/parazite/", "https://the-eye.eu/public/ripreddit/", "https://the-eye.eu/public/rom/", "https://the-eye.eu/public/touhou/", "https://the-eye.eu/public/vns/", "https://the-eye.eu/public/xbins/", "https://the-eye.eu/public/xbins.diodematrix/", "https://the-eye.eu/public/Rclone_for_Scrubs.pdf", "https://the-eye.eu/public/Wget_Linux_Guide.pdf", "https://the-eye.eu/public/Wget_Windows_Guide.pdf", "https://the-eye.eu/public/rclone_guide.pdf", "https://the-eye.eu/public/wget-noobs-guide.pdf", "https://the-eye.eu/public/xbox-scene_Aug2014.7z", } const nginxListing = `
../ AppleArchive/ 03-Nov-2017 18:13 - AudioBooks/ 29-Sep-2018 19:47 - Books/ 27-Nov-2018 17:50 - Comics/ 05-Nov-2018 21:37 - Games/ 28-Nov-2018 11:54 - Icons/ 22-May-2018 07:47 - Images/ 21-Jan-2018 03:21 - JFK_Files/ 03-Nov-2017 17:03 - MSDN/ 03-Nov-2017 15:48 - Music/ 02-Mar-2018 15:47 - Operating Systems/ 25-Apr-2018 07:18 - Posters/ 07-Jul-2018 01:12 - Psychedelics/ 11-Apr-2018 05:45 - Psychoactives/ 18-May-2018 02:58 - Radio/ 09-Jun-2018 15:49 - Random/ 04-Dec-2018 12:33 - Site-Dumps/ 15-Dec-2018 11:04 - Software/ 27-Nov-2017 00:22 - Strategic Intelligence Network/ 17-Nov-2017 16:35 - WorldTracker.org/ 12-Apr-2018 04:16 - concen.org/ 08-Oct-2018 14:08 - freenrg.info/ 19-Dec-2017 10:59 - murdercube.com/ 06-Dec-2017 10:45 - parazite/ 20-Nov-2017 21:25 - ripreddit/ 04-Aug-2018 14:30 - rom/ 28-Nov-2018 14:15 - touhou/ 03-Nov-2017 11:07 - vns/ 03-Nov-2017 11:36 - xbins/ 03-Nov-2017 17:23 - xbins.diodematrix/ 21-Sep-2018 22:33 - Rclone_for_Scrubs.pdf 04-Sep-2018 13:31 315K Wget_Linux_Guide.pdf 21-Dec-2017 20:28 168K Wget_Windows_Guide.pdf 25-Nov-2017 17:59 867K rclone_guide.pdf 03-Sep-2018 23:37 315K wget-noobs-guide.pdf 21-Dec-2017 20:29 168K xbox-scene_Aug2014.7z 26-Oct-2017 23:09 1G