Skip to content

Commit

Permalink
chore(all): merge latest release
Browse files Browse the repository at this point in the history
  • Loading branch information
AureliaEffect committed Sep 10, 2019
1 parent cdc48df commit d0fb4fa
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 9 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# aurelia-path

[![npm Version](https://img.shields.io/npm/v/aurelia-path.svg)](https://www.npmjs.com/package/aurelia-path)
[![ZenHub](https://raw.githubusercontent.com/ZenHubIO/support/master/zenhub-badge.png)](https://zenhub.io)
[![Join the chat at https://gitter.im/aurelia/discuss](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/aurelia/discuss?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![CircleCI](https://circleci.com/gh/aurelia/path.svg?style=shield)](https://circleci.com/gh/aurelia/path)

This library is part of the [Aurelia](http://www.aurelia.io/) platform and contains utilities for path manipulation.

> To keep up to date on [Aurelia](http://www.aurelia.io/), please visit and subscribe to [the official blog](http://blog.aurelia.io/) and [our email list](http://eepurl.com/ces50j). We also invite you to [follow us on twitter](https://twitter.com/aureliaeffect). If you have questions, please [join our community on Gitter](https://gitter.im/aurelia/discuss) or use [stack overflow](http://stackoverflow.com/search?q=aurelia). Documentation can be found [in our developer hub](http://aurelia.io/hub.html). If you would like to have deeper insight into our development process, please install the [ZenHub](https://zenhub.io) Chrome or Firefox Extension and visit any of our repository's boards.
> To keep up to date on [Aurelia](http://www.aurelia.io/), please visit and subscribe to [the official blog](http://blog.aurelia.io/) and [our email list](http://eepurl.com/ces50j). We also invite you to [follow us on twitter](https://twitter.com/aureliaeffect). If you have questions, please [join our community on Gitter](https://gitter.im/aurelia/discuss) or use [stack overflow](http://stackoverflow.com/search?q=aurelia). Documentation can be found [in our developer hub](http://aurelia.io/hub.html).
## Platform Support

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-path",
"version": "1.1.3",
"version": "1.1.4",
"description": "Utilities for path manipulation.",
"keywords": [
"aurelia",
Expand Down
10 changes: 10 additions & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<a name="1.1.4"></a>
## [1.1.4](https://github.com/aurelia/path/compare/1.1.2...1.1.4) (2019-03-26)


### Bug Fixes

* **all:** change es2015 back to native-modules ([3a13e2f](https://github.com/aurelia/path/commit/3a13e2f))



<a name="1.1.3"></a>
## [1.1.3](https://github.com/aurelia/path/compare/1.1.2...1.1.3) (2019-02-04)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-path",
"version": "1.1.3",
"version": "1.1.4",
"description": "Utilities for path manipulation.",
"keywords": [
"aurelia",
Expand Down
15 changes: 13 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,14 @@ export function join(path1: string, path2: string): string {

for (let i = 0, ii = url1.length; i < ii; ++i) {
if (url1[i] === '..') {
url3.pop();
// retain leading ..
// don't pop out previous ..
// retain consecutive ../../..
if (url3.length && url3[url3.length - 1] !== '..') {
url3.pop();
} else {
url3.push(url1[i]);
}
} else if (url1[i] === '.' || url1[i] === '') {
continue;
} else {
Expand All @@ -95,7 +102,11 @@ export function join(path1: string, path2: string): string {

for (let i = 0, ii = url2.length; i < ii; ++i) {
if (url2[i] === '..') {
url3.pop();
if (url3.length && url3[url3.length - 1] !== '..') {
url3.pop();
} else {
url3.push(url2[i]);
}
} else if (url2[i] === '.' || url2[i] === '') {
continue;
} else {
Expand Down
41 changes: 38 additions & 3 deletions test/path.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,41 @@ describe('join', () => {
expect(join(path1, path2)).toBe('one');
});

it('should retain leading .. in path1', () => {
var path1 = '../one';
var path2 = './two';

expect(join(path1, path2)).toBe('../one/two');
});

it('should retain consecutive leading .. in path1', () => {
var path1 = '../../one';
var path2 = './two';

expect(join(path1, path2)).toBe('../../one/two');
});

it('should handle .. in path1 and path2', () => {
var path1 = '../../one';
var path2 = '../two';

expect(join(path1, path2)).toBe('../../two');
});

it('should merge .. in path1 and path2', () => {
var path1 = '../../one';
var path2 = '../../two';

expect(join(path1, path2)).toBe('../../../two');
});

it('should retain consecutive leading .. but not other .. in path1', () => {
var path1 = '../../one/../three';
var path2 = './two';

expect(join(path1, path2)).toBe('../../three/two');
});

it('should respect a trailing slash', () => {
var path1 = 'one/';
var path2 = 'two/';
Expand Down Expand Up @@ -236,7 +271,7 @@ describe('query strings', () => {
expect(gen({ obj: { a: 5, b: "str", c: false } })).toBe('obj%5Ba%5D=5&obj%5Bb%5D=str&obj%5Bc%5D=false');
expect(gen({ obj: { a: 5, b: "str", c: false } }, true)).toBe('obj=%5Bobject%20Object%5D');
expect(gen({ obj:{ a: 5, b: undefined}})).toBe('obj%5Ba%5D=5');

expect(gen({a: {b: ['c','d', ['f', 'g']]}})).toBe('a%5Bb%5D%5B%5D=c&a%5Bb%5D%5B%5D=d&a%5Bb%5D%5B2%5D%5B%5D=f&a%5Bb%5D%5B2%5D%5B%5D=g');
expect(gen({a: {b: ['c','d', ['f', 'g']]}}, true)).toBe('a=%5Bobject%20Object%5D');
expect(gen({a: ['c','d', ['f', 'g']]}, true)).toBe('a=c&a=d&a=f%2Cg');
Expand All @@ -260,14 +295,14 @@ describe('query strings', () => {
expect(parse('a=b&c=d')).toEqual({ a: 'b', c: 'd' });
expect(parse('a=b&&c=d')).toEqual({ a: 'b', c: 'd' });
expect(parse('a=b&a=c')).toEqual({ a: ['b', 'c'] });

expect(parse('a=b&c=d=')).toEqual({ a: 'b', c: 'd' });
expect(parse('a=b&c=d==')).toEqual({ a: 'b', c: 'd' });

expect(parse('a=%26')).toEqual({ a: '&' });
expect(parse('%26=a')).toEqual({ '&': 'a' });
expect(parse('%26[]=b&%26[]=c')).toEqual({ '&': ['b', 'c'] });

expect(parse('a[b]=c&a[d]=e')).toEqual({a: {b: 'c', d: 'e'}});
expect(parse('a[b][c][d]=e')).toEqual({a: {b: {c: {d: 'e'}}}});
expect(parse('a[b][]=c&a[b][]=d&a[b][2][]=f&a[b][2][]=g')).toEqual({a: {b: ['c','d', ['f', 'g']]}});
Expand Down

0 comments on commit d0fb4fa

Please sign in to comment.