Skip to content

Commit

Permalink
feature(relativeTo): resolve /foo/ and /foo/bar to ./ instead o…
Browse files Browse the repository at this point in the history
…f empty string, close #226
  • Loading branch information
rodneyrehm committed Jun 30, 2015
1 parent 5331344 commit 6282417
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,9 @@ URI.js is published under the [MIT license](http://www.opensource.org/licenses/m
### master (will become 1.15.2) ###

* fixing [`URI.parseQuery()`](http://medialize.github.io/URI.js/docs.html#static-parseQuery) to accept `?foo&foo=bar` - [Issue #220](https://github.com/medialize/URI.js/issues/220)
* fixing [`URI.segmentCoded()`](http://medialize.github.io/URI.js/docs.html#accessors-segmentCoded) to encode (instead of decode) array input - [Issue #223](https://github.com/medialize/URI.js/issues/223)
* fixing [`URI.normalizePath()`](http://medialize.github.io/URI.js/docs.html#normalize-path) to properly resolve `/foo/..` to `/` - [Issue #224](https://github.com/medialize/URI.js/issues/224)
* fixing [`.segmentCoded()`](http://medialize.github.io/URI.js/docs.html#accessors-segmentCoded) to encode (instead of decode) array input - [Issue #223](https://github.com/medialize/URI.js/issues/223)
* fixing [`.normalizePath()`](http://medialize.github.io/URI.js/docs.html#normalize-path) to properly resolve `/foo/..` to `/` - [Issue #224](https://github.com/medialize/URI.js/issues/224)
* fixing [`.relativeTo()`](http://medialize.github.io/URI.js/docs.html#relativeto) to resolve `/foo/` and `/foo/bar` to `./` instead of empty string - [Issue #226](https://github.com/medialize/URI.js/issues/226)

### 1.15.1 (April 5th 2015) ###

Expand Down
2 changes: 1 addition & 1 deletion src/URI.js
Original file line number Diff line number Diff line change
Expand Up @@ -2033,7 +2033,7 @@
.replace(/[^\/]*$/, '')
.replace(/.*?\//g, '../');

relativeParts.path = parents + relativeParts.path.substring(common.length);
relativeParts.path = (parents + relativeParts.path.substring(common.length)) || './';

return relative.build();
};
Expand Down
5 changes: 5 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,11 @@
url: '/base/path/with/subdir/inner.html',
base: '/base/path/top.html',
result: 'with/subdir/inner.html'
}, {
name: 'same directory',
url: '/path/',
base: '/path/top.html',
result: './'
}, {
name: 'absolute /',
url: 'http://example.org/foo/bar/bat',
Expand Down

0 comments on commit 6282417

Please sign in to comment.