Skip to content

Commit 8b057a7

Browse files
author
Matthew Lefavor
committed
Responded to PR review comments (round 2).
1. Used more meaningful tags in the documentation. 2. method names with "URN" in them have been camel-cased to use "Urn" instead. 3. A list of resources and a changelog has been added to the README.
1 parent 46b270e commit 8b057a7

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ Documents specifying how URLs work:
158158
* [RFC 3986 - Uniform Resource Identifier (URI): Generic Syntax](http://tools.ietf.org/html/rfc3986)
159159
* [RFC 3987 - Internationalized Resource Identifiers (IRI)](http://tools.ietf.org/html/rfc3987)
160160
* [RFC 2732 - Format for Literal IPv6 Addresses in URL's](http://tools.ietf.org/html/rfc2732)
161+
* [RFC 2368 - The `mailto:` URL Scheme](https://www.ietf.org/rfc/rfc2368.txt)
162+
* [RFC 2141 - URN Syntax](https://www.ietf.org/rfc/rfc2141.txt)
163+
* [IANA URN Namespace Registry](http://www.iana.org/assignments/urn-namespaces/urn-namespaces.xhtml)
161164
* [Punycode: A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA)](http://tools.ietf.org/html/rfc3492)
162165
* [application/x-www-form-urlencoded](http://www.w3.org/TR/REC-html40/interact/forms.html#form-content-type) (Query String Parameters) and [application/x-www-form-urlencoded encoding algorithm](http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#application/x-www-form-urlencoded-encoding-algorithm)
163166
* [What every web developer must know about URL encoding](http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding)
@@ -243,6 +246,7 @@ URI.js is published under the [MIT license](http://www.opensource.org/licenses/m
243246

244247
### master (will become 1.15.0)
245248

249+
* URNs are now normalized based on the syntax given by [RFC 2141](https://www.ietf.org/rfc/rfc2141.txt)
246250
* fixing `URI(undefined)` to throw TypeError - ([Issue #189](https://github.com/medialize/URI.js/issues/189)) - tiny backward-compatibility-break
247251

248252
### 1.14.2 (February 25th 2015) ###

about-uris.html

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ <h2>Understanding URIs</h2>
5050
</p>
5151

5252
<p>
53-
URNs <i>name</i> a resource.
53+
URNs <em>name</em> a resource.
5454
They are (supposed to) designate a globally unique, permanent identifier for that resource.
55-
For example, the URN <code>urn:isbn:0201896834</code> uniquely identifies Volume 1 of Donald Knuth's <i>The Art of Computer Porgramming</i>.
55+
For example, the URN <code>urn:isbn:0201896834</code> uniquely identifies Volume 1 of Donald Knuth's <em>The Art of Computer Porgramming</em>.
5656
Even if that book goes out of print, that URN will continue to identify that particular book in that particular printing.
57-
While the term &quot;URN&quot; <i>technically</i> refers to a specific URI scheme laid out by <a href="http://tools.ietf.org/html/rfc2141">RFC 2141</a>,
57+
While the term &quot;URN&quot; <em>technically</em> refers to a specific URI scheme laid out by <a href="http://tools.ietf.org/html/rfc2141">RFC 2141</a>,
5858
the previously-mentioned RFC 3986 indicates that in common usage &quot;URN&quot; refers to any kind of URI that identifies a resource.
5959
</p>
6060

6161
<p>
62-
URLs <i>locate</i> a resource.
62+
URLs <em>locate</em> a resource.
6363
They designate a protocol to use when looking up the resource and provide an &quot;address&quot; for finding the resource within that scheme.
6464
For example, the URL <code><a href="http://tools.ietf.org/html/rfc3986">http://tools.ietf.org/html/rfc3986</a></code> tells the consumer (most likely a web browser)
6565
to use the HTTP protocol to access whatever site is found at the <code>/html/rfc3986</code> path of <code>tools.ietf.org</code>.
@@ -71,17 +71,16 @@ <h2>Understanding URIs</h2>
7171
<h2>URLs and URNs in URI.js</h2>
7272

7373
<p>
74-
The distinction between URLs and URNs is one of semantics.
74+
The distinction between URLs and URNs is one of <strong>semantics</strong>.
7575
In principle, it is impossible to tell, on a purely syntactical level, whether a given URI is a URN or a URL without knowing more about its scheme.
76-
Practically speaking, however, URIS that look like HTTP URLs (scheme is followed by a colon and two slashes, URI has an authority component, and paths are delimited by slashes) tend to be URLs,
76+
Practically speaking, however, URIs that look like HTTP URLs (scheme is followed by a colon and two slashes, URI has an authority component, and paths are delimited by slashes) tend to be URLs,
7777
and URIs that look like RFC 2141 URNs (scheme is followed by a colon, no authority component, and paths are delimited by colons) tend to be URNs (in the broad sense of &quot;URIs that name&quot;).
7878
</p>
7979

8080
<p>
81-
So, for the purposes of URI.js, the distinction between URLs and URNs is treated as one of syntax.
82-
The main functional differences between the two are that
83-
1) URNs will not have an authority element and
84-
2) when breaking the path of the URI into segments, the colon will be used as the delimiter rather than the slash.
81+
So, for the purposes of URI.js, the distinction between URLs and URNs is treated as one of <strong>syntax</strong>.
82+
The main functional differences between the two are that (1) URNs will not have an authority element and
83+
(2) when breaking the path of the URI into segments, the colon will be used as the delimiter rather than the slash.
8584
The most surprising result of this is that <code>mailto:</code> URLs will be considered by URI.js to be URNs rather than URLs.
8685
That said, the functional differences will not adversely impact the handling of those URLs.
8786
</p>

src/URI.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@
407407

408408
for (_part in _parts) {
409409
URI[_part + 'PathSegment'] = generateAccessor('pathname', _parts[_part]);
410-
URI[_part + 'URNPathSegment'] = generateAccessor('urnpath', _parts[_part]);
410+
URI[_part + 'UrnPathSegment'] = generateAccessor('urnpath', _parts[_part]);
411411
}
412412

413413
var generateSegmentedPathFunction = function(_sep, _codingFuncName, _innerCodingFuncName) {
@@ -435,11 +435,11 @@
435435
};
436436
};
437437

438-
// This takes place outside the above loop because we don't want, e.g., encodeURNPath functions.
438+
// This takes place outside the above loop because we don't want, e.g., encodeUrnPath functions.
439439
URI.decodePath = generateSegmentedPathFunction('/', 'decodePathSegment');
440-
URI.decodeURNPath = generateSegmentedPathFunction(':', 'decodeURNPathSegment');
440+
URI.decodeUrnPath = generateSegmentedPathFunction(':', 'decodeUrnPathSegment');
441441
URI.recodePath = generateSegmentedPathFunction('/', 'encodePathSegment', 'decode');
442-
URI.recodeURNPath = generateSegmentedPathFunction(':', 'encodeURNPathSegment', 'decode');
442+
URI.recodeUrnPath = generateSegmentedPathFunction(':', 'encodeUrnPathSegment', 'decode');
443443

444444
URI.encodeReserved = generateAccessor('reserved', 'encode');
445445

@@ -998,10 +998,10 @@
998998
p.pathname = function(v, build) {
999999
if (v === undefined || v === true) {
10001000
var res = this._parts.path || (this._parts.hostname ? '/' : '');
1001-
return v ? (this._parts.urn ? URI.decodeURNPath : URI.decodePath)(res) : res;
1001+
return v ? (this._parts.urn ? URI.decodeUrnPath : URI.decodePath)(res) : res;
10021002
} else {
10031003
if (this._parts.urn) {
1004-
this._parts.path = v ? URI.recodeURNPath(v) : '';
1004+
this._parts.path = v ? URI.recodeUrnPath(v) : '';
10051005
} else {
10061006
this._parts.path = v ? URI.recodePath(v) : '/';
10071007
}
@@ -1733,7 +1733,7 @@
17331733
}
17341734

17351735
if (this._parts.urn) {
1736-
this._parts.path = URI.recodeURNPath(this._parts.path);
1736+
this._parts.path = URI.recodeUrnPath(this._parts.path);
17371737
this.build(!build);
17381738
return this;
17391739
}

test/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,7 @@
15871587

15881588
equal(URI.decodeQuery('%%20'), '%%20', 'malformed URI component returned');
15891589
equal(URI.decodePathSegment('%%20'), '%%20', 'malformed URI component returned');
1590-
equal(URI.decodeURNPathSegment('%%20'), '%%20', 'malformed URN component returned');
1590+
equal(URI.decodeUrnPathSegment('%%20'), '%%20', 'malformed URN component returned');
15911591
});
15921592
test('encodeQuery', function() {
15931593
var escapeQuerySpace = URI.escapeQuerySpace;

0 commit comments

Comments
 (0)