Mikhus/domurl

Problem with full URL

Closed this issue · 3 comments

Attempt to parse the following URL causes the wrong result

var feed = new Url('https://www.google.com/calendar/feeds/test/private-t42423424234/full?start-index=1&max-results=20');
feed.toString() ->> returns
"https://www.google.com:443calendar/feeds/test/private-t42423424234/full?start-index=1&max-results=20"

There are two problems:

  • missing '/' after the host name
  • default port is present in the result url (not nice)

I have fixed it by changing toString() function to the following. Haven't tested it in all scenarios, by with full URL works fine

this.toString = function () {
return (
(this.protocol && (this.protocol + '://')) +
(this.user && (this.user + (this.pass && (':' + this.pass)) + '@')) +
(this.host && this.host) +
((this.port && !(this.port == 443 && this.protocol == 'https') && !(this.port == 80 && this.protocol == 'http')) ? this.port : '') +
(this.path && ('/' + this.path)) +
(this.query.toString() && ('?' + this.query)) +
(this.hash && ('#' + this.hash))
);
};

Which browser do you use?
I've tested under:

  • Chrome 26
  • Firefox 20
  • Opera 12.15

Works well, bug described above is not reproduced.

IE 9

Sent from my iPhone

On May 6, 2013, at 1:24 PM, Mykhailo Stadnyk notifications@github.com wrote:

What is the browser do you use? I've tested under Chrome 26, it works well, bug described above is not reproduced.


Reply to this email directly or view it on GitHub.

OK, as expected :D, I'll try but it's a bit problematic for the moment as far as I'm on Linux...