-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix URL parsing Get rid of schemify and let url.Parse do the heavy lifting. * Add go test to travis
- Loading branch information
1 parent
28be964
commit c217740
Showing
3 changed files
with
39 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package main | ||
|
||
import "testing" | ||
|
||
func TestParseURL(t *testing.T) { | ||
tests := []struct { | ||
in string | ||
want string | ||
}{ | ||
{"https://golang.org", "https://golang.org"}, | ||
{"https://golang.org:443/test", "https://golang.org:443/test"}, | ||
{"localhost:8080/test", "https://localhost:8080/test"}, | ||
{"localhost:80/test", "http://localhost:80/test"}, | ||
{"//localhost:8080/test", "https://localhost:8080/test"}, | ||
{"//localhost:80/test", "http://localhost:80/test"}, | ||
} | ||
|
||
for _, test := range tests { | ||
u := parseURL(test.in) | ||
if u.String() != test.want { | ||
t.Errorf("Given: %s\nwant: %s\ngot: %s", test.in, test.want, u.String()) | ||
} | ||
} | ||
} |