Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Fix url.parse() leaving trailing ':' on protocol
Browse files Browse the repository at this point in the history
Before:
    % node -e 'require("url").parse("http://www.google.com/").protocol'
    http:

After:
    % node -e 'require("url").parse("http://www.google.com/").protocol'
    http
  • Loading branch information
jordansissel committed Aug 23, 2011
1 parent 509a676 commit 7fd62d9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exports.format = urlFormat;

// define these here so at least they only have to be
// compiled once on the first module load.
var protocolPattern = /^([a-z0-9]+:)/i,
var protocolPattern = /^([a-z0-9]+):/i,
portPattern = /:[0-9]+$/,
// RFC 2396: characters reserved for delimiting URLs.
delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
Expand Down Expand Up @@ -99,7 +99,7 @@ function urlParse(url, parseQueryString, slashesDenoteHost) {

var proto = protocolPattern.exec(rest);
if (proto) {
proto = proto[0];
proto = proto[1];
var lowerProto = proto.toLowerCase();
out.protocol = lowerProto;
rest = rest.substr(proto.length);
Expand Down

0 comments on commit 7fd62d9

Please sign in to comment.