From 42799df06eb571dd389edc51045f30c008484185 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Sun, 15 Feb 2015 08:20:00 -0800 Subject: [PATCH] add initial failing test for cleanURL --- src/docrawler/url.go | 3 +++ src/docrawler/url_test.go | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/docrawler/url.go create mode 100644 src/docrawler/url_test.go diff --git a/src/docrawler/url.go b/src/docrawler/url.go new file mode 100644 index 0000000..055886f --- /dev/null +++ b/src/docrawler/url.go @@ -0,0 +1,3 @@ +package main + +// scheme://[userinfo@]host/path[?query][#fragment] diff --git a/src/docrawler/url_test.go b/src/docrawler/url_test.go new file mode 100644 index 0000000..ef08652 --- /dev/null +++ b/src/docrawler/url_test.go @@ -0,0 +1,16 @@ +package main + +import ( + "testing" +) + +// TestURLCleaner tests cleaning up (regularization) of URLs +func TestURLCleaner(t *testing.T) { + host, url := cleanURL("http://swaits:pass@someHOST.com:8765/blah/blah.html?x=y#foo") + if host != "somehost.com" { + t.Error("host extraction failed") + } + if url != "http://swaits:pass@somehost.com:8765/blah/blah.html?x=y#foo" { + t.Error("url cleanup failed") + } +}