Skip to content

Commit

Permalink
Merge branch 'master' into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
rodneyrehm committed Sep 19, 2015
2 parents 1a73262 + f406808 commit 2bad611
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 130 deletions.
41 changes: 22 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

---

> **NOTE:** The npm package name changed to `urijs`
---

I always want to shoot myself in the head when looking at code like the following:

```javascript
Expand All @@ -17,9 +21,7 @@ var separator = url.indexOf('?') > -1 ? '&' : '?';
url += separator + encodeURIComponent("foo") + "=" + encodeURIComponent("bar");
```

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 convenience at all.

How about a nice, clean and simple API for mutating URIs:
Things are looking up with [URL](https://developer.mozilla.org/en/docs/Web/API/URL) and the [URL spec](http://url.spec.whatwg.org/) but until we can safely rely on that API, have a look at URI.js for a clean and simple API for mutating URIs:

```javascript
var url = new URI("http://example.org/foo?bar=baz");
Expand Down Expand Up @@ -79,20 +81,14 @@ See the [About Page](http://medialize.github.io/URI.js/) and [API Docs](http://m

URI.js (without plugins) has a gzipped weight of about 7KB - if you include all extensions you end up at about 13KB. So unless you *need* second level domain support and use URI templates, we suggest you don't include them in your build. If you don't need a full featured URI mangler, it may be worth looking into the much smaller parser-only alternatives [listed below](#alternatives).

URI.js is available through [npm](http://npmjs.org/), [bower](http://bower.io/), [Jam](http://jamjs.org/), [spm](http://spmjs.io/) and manually from the [build page](http://medialize.github.io/URI.js/build.html):
URI.js is available through [npm](https://www.npmjs.com/package/urijs), [bower](http://bower.io/search/?q=urijs), [cdnjs](https://cdnjs.com/libraries/URI.js) and manually from the [build page](http://medialize.github.io/URI.js/build.html):

```bash
# using bower
bower install uri.js

# using Jam
jam install URIjs

# using npm
npm install URIjs

# using spm
spm install urijs
npm install urijs
```

### Browser ###
Expand All @@ -101,13 +97,13 @@ I guess you'll manage to use the [build tool](http://medialize.github.io/URI.js/

### Node.js and NPM ###

Install with `npm install URIjs` or add `"URIjs"` to the dependencies in your `package.json`.
Install with `npm install urijs` or add `"urijs"` to the dependencies in your `package.json`.

```javascript
// load URI.js
var URI = require('URIjs');
var URI = require('urijs');
// load an optional module (e.g. URITemplate)
var URITemplate = require('URIjs/src/URITemplate');
var URITemplate = require('urijs/src/URITemplate');

URI("/foo/bar/baz.html")
.relativeTo("/foo/bar/sub/world.html")
Expand All @@ -121,14 +117,14 @@ Clone the URI.js repository or use a package manager to get URI.js into your pro
```javascript
require.config({
paths: {
URIjs: 'where-you-put-uri.js/src'
urijs: 'where-you-put-uri.js/src'
}
});

require(['URIjs/URI'], function(URI) {
require(['urijs/URI'], function(URI) {
console.log("URI.js and dependencies: ", URI("//amazon.co.uk").is('sld') ? 'loaded' : 'failed');
});
require(['URIjs/URITemplate'], function(URITemplate) {
require(['urijs/URITemplate'], function(URITemplate) {
console.log("URITemplate.js and dependencies: ", URITemplate._cache ? 'loaded' : 'failed');
});
```
Expand Down Expand Up @@ -199,14 +195,14 @@ If you don't like URI.js, you may like one of the following libraries. (If yours
* [furl (Python)](https://github.com/gruns/furl)
* [mediawiki Uri](https://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/resources/mediawiki/mediawiki.Uri.js?view=markup) (needs mw and jQuery)
* [jurlp](https://github.com/tombonner/jurlp)
* [jsUri](http://code.google.com/p/jsuri/)
* [jsUri](https://github.com/derek-watson/jsUri)

#### URL Parsers ####

* [The simple <a> URL Mutation "Hack"](http://jsfiddle.net/rodneyrehm/KkGUJ/) ([jsPerf comparison](http://jsperf.com/idl-attributes-vs-uri-js))
* [URI Parser](http://blog.stevenlevithan.com/archives/parseuri)
* [jQuery-URL-Parser](https://github.com/allmarkedup/jQuery-URL-Parser)
* [Google Closure Uri](http://closure-library.googlecode.com/svn/docs/closure_goog_uri_uri.js.html)
* [Google Closure Uri](https://google.github.io/closure-library/api/class_goog_Uri.html)
* [URI.js by Gary Court](https://github.com/garycourt/uri-js)

#### URI Template ####
Expand Down Expand Up @@ -244,6 +240,13 @@ URI.js is published under the [MIT license](http://www.opensource.org/licenses/m

## Changelog ##

### 1.16.1 (September 19th 2015) ###

Package Management Cleanup - no changes to source code!

* renaming package to "urijs", was "URIjs" (because npm decided to go lower-case at some point and maintaining capitals in your package name poses all sorts of stupid issues)
* removing [jam](http://jamjs.org/), [spm](http://spmjs.org/), `component.json` and `URI.jquery.json` as nobody cared that URI.js was stuck on 1.14 for a year

### 1.16.0 (July 24th 2015) ###

* **SECURITY** fixing [`URI.parseHost()`](http://medialize.github.io/URI.js/docs.html#static-parseHost) to rewrite `\` to `/` as Node and Browsers do - [Issue #233](https://github.com/medialize/URI.js/pull/233)
Expand Down
38 changes: 0 additions & 38 deletions URI.jquery.json

This file was deleted.

4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "URIjs",
"version": "1.16.0",
"name": "urijs",
"version": "1.16.1",
"main": "src/URI.js",
"ignore": [
".*",
Expand Down
2 changes: 1 addition & 1 deletion build.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function build(files) {
output_format: "text",
output_info: "compiled_code"
}, function(data) {
var code = "/*! URI.js v1.16.0 http://medialize.github.io/URI.js/ */\n/* build contains: " + files.join(', ') + " */\n" + data;
var code = "/*! URI.js v1.16.1 http://medialize.github.io/URI.js/ */\n/* build contains: " + files.join(', ') + " */\n" + data;
$progress.hide();
$out.val(code).parent().show();
$out.prev().find('a').remove();
Expand Down
37 changes: 0 additions & 37 deletions component.json

This file was deleted.

4 changes: 2 additions & 2 deletions docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ <h3 id="constructor">URI Constructor</h3>
// URI parts object
var uri = new URI({
protocol: "http",
host: "example.org"
hostname: "example.org"
});

// without new keyword
Expand Down Expand Up @@ -1140,7 +1140,7 @@ <h3 id="static-encode">URI.encode()</h3>

<h3 id="static-decode">URI.decode()</h3>
<p>Decode an URI component</p>
<pre class="prettyprint lang-js">URI.encode("h%C3%A4%20lo%23w%2Arl%3Ad%21") === "hä lo#w*rl:d!";
<pre class="prettyprint lang-js">URI.decode("h%C3%A4%20lo%23w%2Arl%3Ad%21") === "hä lo#w*rl:d!";
// note:
URI.decode === decodeURIComponent;</pre>

Expand Down
25 changes: 3 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "URIjs",
"version": "1.16.0",
"name": "urijs",
"version": "1.16.1",
"title": "URI.js - Mutating URLs",
"author": {
"name": "Rodney Rehm",
Expand Down Expand Up @@ -54,23 +54,7 @@
"src/URI.fragmentURI.js",
"LICENSE.txt"
],
"jam": {
"main": "src/URI.js",
"include": [
"src/URI.js",
"src/IPv6.js",
"src/SecondLevelDomains.js",
"src/punycode.js",
"src/URITemplate.js",
"src/jquery.URI.js",
"src/URI.min.js",
"src/jquery.URI.min.js",
"src/URI.fragmentQuery.js",
"src/URI.fragmentURI.js",
"LICENSE.txt"
]
},
"npmName": "URIjs",
"npmName": "urijs",
"npmFileMap": [
{
"basePath": "/src/",
Expand All @@ -89,8 +73,5 @@
"jshint-stylish": "~0.1.5",
"grunt": "~0.4.2",
"grunt-contrib-jshint": "~0.8.0"
},
"spm": {
"main": "src/URI.js"
}
}
2 changes: 1 addition & 1 deletion src/IPv6.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* URI.js - Mutating URLs
* IPv6 Support
*
* Version: 1.16.0
* Version: 1.16.1
*
* Author: Rodney Rehm
* Web: http://medialize.github.io/URI.js/
Expand Down
2 changes: 1 addition & 1 deletion src/SecondLevelDomains.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* URI.js - Mutating URLs
* Second Level Domain (SLD) Support
*
* Version: 1.16.0
* Version: 1.16.1
*
* Author: Rodney Rehm
* Web: http://medialize.github.io/URI.js/
Expand Down
4 changes: 2 additions & 2 deletions src/URI.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* URI.js - Mutating URLs
*
* Version: 1.16.0
* Version: 1.16.1
*
* Author: Rodney Rehm
* Web: http://medialize.github.io/URI.js/
Expand Down Expand Up @@ -72,7 +72,7 @@
return this;
}

URI.version = '1.16.0';
URI.version = '1.16.1';

var p = URI.prototype;
var hasOwn = Object.prototype.hasOwnProperty;
Expand Down
4 changes: 2 additions & 2 deletions src/URI.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/URITemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* URI.js - Mutating URLs
* URI Template Support - http://tools.ietf.org/html/rfc6570
*
* Version: 1.16.0
* Version: 1.16.1
*
* Author: Rodney Rehm
* Web: http://medialize.github.io/URI.js/
Expand Down
2 changes: 1 addition & 1 deletion src/jquery.URI.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* URI.js - Mutating URLs
* jQuery Plugin
*
* Version: 1.16.0
* Version: 1.16.1
*
* Author: Rodney Rehm
* Web: http://medialize.github.io/URI.js/jquery-uri-plugin.html
Expand Down
2 changes: 1 addition & 1 deletion src/jquery.URI.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2bad611

Please sign in to comment.