While playing with URI.js, I stumbled across a problem. Here's some sample code to illustrate the point, as copied from my Chrome's script console.
URI(document.location).toString()
"https:://example.com/somePage.html"
This seems to boil down to how URI handles the protocol.
URI(document.location).protocol()
"https:"
URI(document.location.toString()).protocol()
"https"
document.location.protocol
"https:"
It looks like .protocol can contain a colon and that seems to mess up URI.build on line 365:
if (parts.protocol) {
t += parts.protocol + ":";
}
I'm wondering if this would make sense:
if (parts.protocol && parts.protocol.charAt(parts.protocol.length - 1) != ':') {
t += parts.protocol + ":";
}