aboutsummaryrefslogtreecommitdiffstats
path: root/skate/url_test.go
blob: ffa315cf420b839ec44f6240053dda51d1cb339f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package skate

import "testing"

func TestSanitizeURL(t *testing.T) {
	var cases = []struct {
		in  string
		out string
	}{
		{"", ""},
		{"http://abc.com", "http://abc.com"},
		{"http://!!abc.com", "http://abc.com"},
		{`http://"www.phaelos.com/oubre.html`, `http://www.phaelos.com/oubre.html`},
		{`http://!www.rkm=journal.de/archives/13383`, `http://www.rkm=journal.de/archives/13383`},
		{`http:///en.m.wikipedia.org/ChenLong`, `http://en.m.wikipedia.org/ChenLong`},
		{`http://10.1111/joim.12348`, `https://doi.org/10.1111/joim.12348`},
		{`http://10.1113/jphysiol.2002.026047`, `https://doi.org/10.1113/jphysiol.2002.026047`},
		{`http://10.30.3.16/moodle/course/view.php?id=25`, `http://10.30.3.16/moodle/course/view.php?id=25`},
		{`http://10.3266/RevEspEndocrinolPediatr.pre2015.Nov.330`, `https://doi.org/10.3266/RevEspEndocrinolPediatr.pre2015.Nov.330`},
		{`http://120.107.180.177/1832/9901/099-2-07p.pdf.Accessed`, `http://120.107.180.177/1832/9901/099-2-07p.pdf`},
		{`http://120cartas.ig.com.br/wp/maio-de-2008-um-aniversario-de-120-anos/.Acessoem:set`,
			`http://120cartas.ig.com.br/wp/maio-de-2008-um-aniversario-de-120-anos/`},
		{`http://122.53.86.125/NNS/8thNNS.pdf.Accessed`, `http://122.53.86.125/NNS/8thNNS.pdf`},
		{`http://122.53.86.125/facts_figures2011.pdf.Accessedon`,
			`http://122.53.86.125/facts_figures2011.pdf`},
		{`http://129.3.20.41/eps/fin/papers/0507/0507016.pdf.diaksespadatanggal23Januari`,
			`http://129.3.20.41/eps/fin/papers/0507/0507016.pdf`},
		{`http://129.3.20.41/eps/hew/papers/0512/0512001.pdfAccessed1`,
			`http://129.3.20.41/eps/hew/papers/0512/0512001.pdf`},
		{`http://140.120.197.173/Ecology/Download/Timing-MSChart.zipJournalofInsectScience`,
			`http://140.120.197.173/Ecology/Download/Timing-MSChart.zip`},
		{`141.213.232.243/bitstream/handle/2027.42/86336/apterc_1.pdf?sequence=1`,
			`141.213.232.243/bitstream/handle/2027.42/86336/apterc_1.pdf?sequence=1`},
		{`http://141.232.10.32/pm/recover/recover_docs/perf_measures/062812_rec_pm_scs_salinity_flbay.pdfRECOVER`,
			`http://141.232.10.32/pm/recover/recover_docs/perf_measures/062812_rec_pm_scs_salinity_flbay.pdf`},
		{`http://2010.census.gov/news/releases/operations/cb11-cn125.html.lastaccessed4`,
			`http://2010.census.gov/news/releases/operations/cb11-cn125.html`},
		{`http://2014hit.blogspot.com.tr/2014/12/george-gerbnerin-tv-arastrmas-ve-ekme.htmladresindenedinilmiştir`,
			`http://2014hit.blogspot.com.tr/2014/12/george-gerbnerin-tv-arastrmas-ve-ekme.html`},
		{`http://2015.ses.org.tr/wp-ontent/uploads/toplumsalcinsiyetrolleri.pdfsayfasındanulaşıl-mıştır`,
			`http://2015.ses.org.tr/wp-ontent/uploads/toplumsalcinsiyetrolleri.pdf`},
		{`http://2015.veneziabiennale-japanpavilion.jp/en/Consultadael20deoctubrealas14`,
			`http://2015.veneziabiennale-japanpavilion.jp/en/`},
		{`http://-annalsofneurosciences.org/journal/index.php/annal/article/view/43/67`,
			`http://annalsofneurosciences.org/journal/index.php/annal/article/view/43/67`},
	}
	for _, c := range cases {
		out := SanitizeURL(c.in)
		if out != c.out {
			t.Fatalf("got %v, want %v", out, c.out)
		}
	}
}