Strip URL of path and query string

Mike Abdullah:

Sometimes you might want to strip a URL back so it has no path, parameter, query or fragment. e.g. to go from:

http://example.com/path;param?query#fragment

to:

http://example.com/

Here’s the trick.