Skip to content

Commit

Permalink
fixing URI.protocol_expression to accept . - closing #132
Browse files Browse the repository at this point in the history
  • Loading branch information
rodneyrehm committed Jan 22, 2014
1 parent 12d82e7 commit 4786e04
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ URI.js is published under the [MIT license](http://www.opensource.org/licenses/m

* fixing [`.absoluteTo()`](http://medialize.github.com/URI.js/docs.html#absoluteto) to comply with [RFC3986 Reference Resolution Examples](http://tools.ietf.org/html/rfc3986#section-5.4) - ([Issue #113](https://github.com/medialize/URI.js/issues/113))
* fixing [`.normalizePath()`](http://medialize.github.com/URI.js/docs.html#normalize-path) to maintain leading parent references (`../`) for relative paths, while removing them for absolute paths - ([Issue #133](https://github.com/medialize/URI.js/issues/133))
* fixing `URI.protocol_expression` to properly accept `.` in compliance with [RFC 3986 - Scheme](http://tools.ietf.org/html/rfc3986#section-3.1) - ([Issue #132](https://github.com/medialize/URI.js/issues/132))

### 1.11.2 (August 14th 2013) ###

Expand Down
6 changes: 3 additions & 3 deletions src/URI.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ URI.duplicateQueryParameters = false;
// state: replaces + with %20 (space in query strings)
URI.escapeQuerySpace = true;
// static properties
URI.protocol_expression = /^[a-z][a-z0-9-+-]*$/i;
URI.protocol_expression = /^[a-z][a-z0-9.+-]*$/i;
URI.idn_expression = /[^a-z0-9\.-]/i;
URI.punycode_expression = /(xn--)/i;
// well, 333.444.555.666 matches, but it sure ain't no IPv4 - do we care?
Expand Down Expand Up @@ -1019,8 +1019,8 @@ p.protocol = function(v, build) {
// accept trailing ://
v = v.replace(/:(\/\/)?$/, '');

if (v.match(/[^a-zA-z0-9\.+-]/)) {
throw new TypeError("Protocol '" + v + "' contains characters other than [A-Z0-9.+-]");
if (!v.match(URI.protocol_expression)) {
throw new TypeError("Protocol '" + v + "' contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ test("protocol", function() {
equal(u.protocol(), "", "relative protocol");
equal(u+"", "//example.org/foo.html", "relative-scheme url");

u.protocol('f.t-p+0');
equal(u.protocol(), "f.t-p+0", "character profile");

try {
u.protocol('f:t');
ok(false, "do not accept invalid protocol");
} catch(e) {}

u.protocol(null);
equal(u.protocol(), "", "missing protocol");
equal(u+"", "//example.org/foo.html", "missing-scheme url");
Expand Down

0 comments on commit 4786e04

Please sign in to comment.