Comparing version 1.8.1 to 1.8.2
{ | ||
"name": "URIjs", | ||
"version": "1.8.1", | ||
"version": "1.8.2", | ||
"title": "URI.js - Mutating URLs", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -210,2 +210,8 @@ # URI.js # | ||
### 1.8.2 (December 27th 2012) ### | ||
* adding `.fragmentPrefix()` to configure prefix of fragmentURI and fragmentQuery extensions - ([Issue #55](https://github.com/medialize/URI.js/issues/55)) | ||
* adding docs for [`.toString()`, `.valueOf()`](http://medialize.github.com/URI.js/docs.html#toString) and [`.href()`](http://medialize.github.com/URI.js/docs.html#href) - ([Issue #56](https://github.com/medialize/URI.js/issues/56)) | ||
* fixing [`.relativeTo()`](http://medialize.github.com/URI.js/docs.html#relativeto) for descendants - ([Issue #57](https://github.com/medialize/URI.js/issues/57)) | ||
### 1.8.1 (November 15th 2012) ### | ||
@@ -212,0 +218,0 @@ |
@@ -5,3 +5,3 @@ /*! | ||
* | ||
* Version: 1.8.1 | ||
* Version: 1.8.2 | ||
* | ||
@@ -8,0 +8,0 @@ * Author: Rodney Rehm |
@@ -5,3 +5,3 @@ /*! | ||
* | ||
* Version: 1.8.1 | ||
* Version: 1.8.2 | ||
* | ||
@@ -8,0 +8,0 @@ * Author: Rodney Rehm |
@@ -5,3 +5,3 @@ /*! | ||
* | ||
* Version: 1.8.1 | ||
* Version: 1.8.2 | ||
* | ||
@@ -8,0 +8,0 @@ * Author: Rodney Rehm |
/*! | ||
* URI.js - Mutating URLs | ||
* | ||
* Version: 1.8.1 | ||
* Version: 1.8.2 | ||
* | ||
@@ -88,2 +88,17 @@ * Author: Rodney Rehm | ||
URI._parts = function() { | ||
return { | ||
protocol: null, | ||
username: null, | ||
password: null, | ||
hostname: null, | ||
urn: null, | ||
port: null, | ||
path: null, | ||
query: null, | ||
fragment: null, | ||
// state | ||
duplicateQueryParameters: URI.duplicateQueryParameters | ||
}; | ||
}; | ||
// state: allow duplicate query parameters (a=1&a=1) | ||
@@ -626,3 +641,3 @@ URI.duplicateQueryParameters = false; | ||
for (_part in _parts) { | ||
for (_part in _parts) { | ||
p[_part] = generateAccessor(_parts[_part]); | ||
@@ -681,2 +696,4 @@ } | ||
p.href = function(href, build) { | ||
var key; | ||
if (href === undefined) { | ||
@@ -687,19 +704,7 @@ return this.toString(); | ||
this._string = ""; | ||
this._parts = { | ||
protocol: null, | ||
username: null, | ||
password: null, | ||
hostname: null, | ||
urn: null, | ||
port: null, | ||
path: null, | ||
query: null, | ||
fragment: null, | ||
// state | ||
duplicateQueryParameters: URI.duplicateQueryParameters | ||
}; | ||
this._parts = URI._parts(); | ||
var _URI = href instanceof URI; | ||
var _object = typeof href === "object" && (href.hostname || href.path); | ||
var key; | ||
@@ -1514,3 +1519,3 @@ // window.location is reported to be an object, but it's not the sort | ||
var properties = ['protocol', 'username', 'password', 'hostname', 'port']; | ||
var common, _base; | ||
var common, _base, _this, _base_diff, _this_diff; | ||
@@ -1529,29 +1534,48 @@ if (this._parts.urn) { | ||
// determine common sub path | ||
common = URI.commonPath(relative.path(), base.path()); | ||
_base = base.directory(); | ||
// no relation if there's nothing in common | ||
if (!common || common === '/') { | ||
return relative; | ||
} | ||
// relative paths don't have authority | ||
for (var i = 0, p; p = properties[i]; i++) { | ||
relative._parts[p] = null; | ||
} | ||
if (!common || common === '/') { | ||
return relative; | ||
_base = base.directory(); | ||
_this = this.directory(); | ||
// base and this are on the same level | ||
if (_base === _this) { | ||
relative._parts.path = './' + relative.filename(); | ||
return relative.build(); | ||
} | ||
_base_diff = _base.substring(common.length); | ||
_this_diff = _this.substring(common.length); | ||
// this is a descendant of base | ||
if (_base + '/' === common) { | ||
relative._parts.path = './' + relative.filename(); | ||
} else { | ||
var parents = '../'; | ||
var _common = new RegExp('^' + escapeRegEx(common)); | ||
var _parents = _base.replace(_common, '/').match(/\//g).length -1; | ||
while (_parents--) { | ||
parents += '../'; | ||
if (_this_diff) { | ||
_this_diff += '/'; | ||
} | ||
relative._parts.path = './' + _this_diff + relative.filename(); | ||
return relative.build(); | ||
} | ||
relative._parts.path = relative._parts.path.replace(_common, parents); | ||
// this is a descendant of base | ||
var parents = '../'; | ||
var _common = new RegExp('^' + escapeRegEx(common)); | ||
var _parents = _base.replace(_common, '/').match(/\//g).length -1; | ||
while (_parents--) { | ||
parents += '../'; | ||
} | ||
relative.build(); | ||
return relative; | ||
relative._parts.path = relative._parts.path.replace(_common, parents); | ||
return relative.build(); | ||
}; | ||
@@ -1558,0 +1582,0 @@ |
@@ -5,3 +5,3 @@ /*! | ||
* | ||
* Version: 1.8.1 | ||
* Version: 1.8.2 | ||
* | ||
@@ -8,0 +8,0 @@ * Author: Rodney Rehm |
118777
2878
347