Skip to content

Commit f06773a

Browse files
committed
Readme.md updated
1 parent 971f538 commit f06773a

3 files changed

Lines changed: 30 additions & 14 deletions

File tree

README.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var url = "http://example.org/foo?bar=baz",
1414
url += separator + encodeURIComponent("foo") + "=" + encodeURIComponent("bar");
1515
```
1616

17-
I still can't believe javascript - the f**ing backbone-language of the web - doesn't offer an API for mutating URLs. Browsers (Firefox) don't expose the `Location` object (the structure behind window.location). Yes, one could think of [decomposed IDL attributes](http://www.whatwg.org/specs/web-apps/current-work/multipage/urls.html#url-decomposition-idl-attributes) as a native URL management library. But it relies on the DOM element <a>, it's slow and doesn't offer any convenienve at all.
17+
I still can't believe javascript - the f**ing backbone-language of the web - doesn't offer an API for mutating URLs. Browsers (Firefox) don't expose the `Location` object (the structure behind window.location). Yes, one could think of [decomposed IDL attributes](http://www.whatwg.org/specs/web-apps/current-work/multipage/urls.html#url-decomposition-idl-attributes) as a native URL management library. But it relies on the DOM element <a>, it's slow and doesn't offer any convenienve at all.
1818

1919
How about a nice, clean and simple API for mutating URIs:
2020

@@ -31,17 +31,17 @@ URI.js is here to help with that.
3131
```javascript
3232
// mutating URLs
3333
URI("http://example.org/foo.html?hello=world")
34-
.username("rodneyrehm")
34+
.username("rodneyrehm")
3535
// -> http://rodneyrehm@example.org/foo.html?hello=world
36-
.username("")
36+
.username("")
3737
// -> http://example.org/foo.html?hello=world
3838
.directory("bar")
3939
// -> http://example.org/bar/foo.html?hello=world
40-
.suffix("xml")
40+
.suffix("xml")
4141
// -> http://example.org/bar/foo.xml?hello=world
42-
.query("")
42+
.query("")
4343
// -> http://example.org/bar/foo.xml
44-
.tld("com")
44+
.tld("com")
4545
// -> http://example.com/bar/foo.xml
4646
.query({ foo: "bar", hello: ["world", "mars"] });
4747
// -> http://example.com/bar/foo.xml?foo=bar&hello=world&hello=mars
@@ -65,6 +65,22 @@ URI("/foo/bar/baz.html")
6565

6666
See the [About Page](http://medialize.github.com/URI.js/) and [API Docs](http://medialize.github.com/URI.js/docs.html) for more stuff.
6767

68+
## npm ##
69+
70+
```
71+
npm install URIjs
72+
```
73+
74+
75+
## Server-side JS ##
76+
77+
```javascript
78+
var URI = require('URIJS');
79+
80+
URI("/foo/bar/baz.html")
81+
.relativeTo("/foo/bar/sub/world.html")
82+
// -> ../baz.html
83+
```
6884

6985
## Minify ##
7086

@@ -77,7 +93,7 @@ use [Google Closure Compiler](http://closure-compiler.appspot.com/home):
7793
// @code_url http://medialize.github.com/URI.js/src/IPv6.js
7894
// @code_url http://medialize.github.com/URI.js/src/punycode.js
7995
// @code_url http://medialize.github.com/URI.js/src/URI.js
80-
// ==/ClosureCompiler==
96+
// ==/ClosureCompiler==
8197
```
8298

8399
## Resources ##
@@ -152,7 +168,7 @@ I built this sucker during Christmas 2011. It was a nice excuse to get away from
152168

153169
```
154170
Quote from java doc:
155-
A URI is a uniform resource identifier while a URL is a uniform resource locator. Hence every URL is a URI, abstractly speaking, but not every URI is a URL. This is because there is another subcategory of URIs, uniform resource names (URNs), which name resources but do not specify how to locate them. The mailto, news, and isbn URIs shown above are examples of URNs.
171+
A URI is a uniform resource identifier while a URL is a uniform resource locator. Hence every URL is a URI, abstractly speaking, but not every URI is a URL. This is because there is another subcategory of URIs, uniform resource names (URNs), which name resources but do not specify how to locate them. The mailto, news, and isbn URIs shown above are examples of URNs.
156172
```
157173

158174
URI.js only handles URLs - but since Firefox already used window.URL for some (yet undocumented) MozURLProperty, I named it URI anyways.
@@ -179,7 +195,7 @@ URI.js is published under the [MIT license](http://www.opensource.org/licenses/m
179195
* Updated Punycode.js to version 0.3.0
180196
* added edge-case tests ("jim")
181197
* fixed edge-cases in .protocol(), .port(), .subdomain(), .domain(), .tld(), .filename()
182-
* fixed parsing of hostname in .hostname()
198+
* fixed parsing of hostname in .hostname()
183199

184200
### 1.3.0 ###
185201

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "URI.js",
2+
"name": "URIjs",
33
"version": "1.4.1",
44
"title": "URI.js - Mutating URLs",
55
"author": {
@@ -14,7 +14,7 @@
1414
{
1515
"type": "GPL",
1616
"url": "http://opensource.org/licenses/GPL-3.0"
17-
}
17+
}
1818
],
1919
"description": "URI.js is a Javascript library for working with URLs.",
2020
"keywords": [

src/URI.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ p.equals = function(uri) {
13021302
};
13031303

13041304
(typeof module !== 'undefined' && module.exports ?
1305-
module.exports
1306-
: window
1307-
).URI = URI;
1305+
module.exports = URI
1306+
: window.URI = URI
1307+
);
13081308
})();

0 commit comments

Comments
 (0)