Skip to content

Commit

Permalink
chore(*): prepare release 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Dec 16, 2014
1 parent 61f7e56 commit d1e83ff
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 52 deletions.
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": "0.1.0",
"version": "0.2.0",
"keywords": [
"aurelia",
"path"
Expand Down
46 changes: 31 additions & 15 deletions dist/amd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@ define(["exports"], function (exports) {
"use strict";

exports.normalize = normalize;
exports.join = join;
function trimDots(ary) {
var i, part;
for (i = 0; i < ary.length; i++) {
part = ary[i];
if (part === ".") {
ary.splice(i, 1);
i -= 1;
} else if (part === "..") {
if (i === 0 || (i == 1 && ary[2] === "..") || ary[i - 1] === "..") {
continue;
} else if (i > 0) {
ary.splice(i - 1, 2);
i -= 2;
}
}
}
}

function normalize(name, baseName) {
var lastIndex, normalizedBaseParts, baseParts = (baseName && baseName.split("/"));

Expand All @@ -18,21 +37,18 @@ define(["exports"], function (exports) {
return name.join("/");
}

function trimDots(ary) {
var i, part;
for (i = 0; i < ary.length; i++) {
part = ary[i];
if (part === ".") {
ary.splice(i, 1);
i -= 1;
} else if (part === "..") {
if (i === 0 || (i == 1 && ary[2] === "..") || ary[i - 1] === "..") {
continue;
} else if (i > 0) {
ary.splice(i - 1, 2);
i -= 2;
}
}
function join() {
var parts = [];
for (var i = 0, l = arguments.length; i < l; i++) {
parts = parts.concat(arguments[i].split("/"));
}
var newParts = [];
for (i = 0, l = parts.length; i < l; i++) {
var part = parts[i];
if (!part || part === ".") continue;
if (part === "..") newParts.pop();else newParts.push(part);
}
if (parts[0] === "") newParts.unshift("");
return newParts.join("/") || (newParts.length ? "/" : ".");
}
});
46 changes: 31 additions & 15 deletions dist/commonjs/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
"use strict";

exports.normalize = normalize;
exports.join = join;
function trimDots(ary) {
var i, part;
for (i = 0; i < ary.length; i++) {
part = ary[i];
if (part === ".") {
ary.splice(i, 1);
i -= 1;
} else if (part === "..") {
if (i === 0 || (i == 1 && ary[2] === "..") || ary[i - 1] === "..") {
continue;
} else if (i > 0) {
ary.splice(i - 1, 2);
i -= 2;
}
}
}
}

function normalize(name, baseName) {
var lastIndex, normalizedBaseParts, baseParts = (baseName && baseName.split("/"));

Expand All @@ -17,20 +36,17 @@ function normalize(name, baseName) {
return name.join("/");
}

function trimDots(ary) {
var i, part;
for (i = 0; i < ary.length; i++) {
part = ary[i];
if (part === ".") {
ary.splice(i, 1);
i -= 1;
} else if (part === "..") {
if (i === 0 || (i == 1 && ary[2] === "..") || ary[i - 1] === "..") {
continue;
} else if (i > 0) {
ary.splice(i - 1, 2);
i -= 2;
}
}
function join() {
var parts = [];
for (var i = 0, l = arguments.length; i < l; i++) {
parts = parts.concat(arguments[i].split("/"));
}
var newParts = [];
for (i = 0, l = parts.length; i < l; i++) {
var part = parts[i];
if (!part || part === ".") continue;
if (part === "..") newParts.pop();else newParts.push(part);
}
if (parts[0] === "") newParts.unshift("");
return newParts.join("/") || (newParts.length ? "/" : ".");
}
67 changes: 47 additions & 20 deletions dist/es6/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
function trimDots(ary) {
var i, part;
for (i = 0; i < ary.length; i++) {
part = ary[i];
if (part === '.') {
ary.splice(i, 1);
i -= 1;
} else if (part === '..') {
// If at the start, or previous value is still ..,
// keep them so that when converted to a path it may
// still work when converted to a path, even though
// as an ID it is less than ideal. In larger point
// releases, may be better to just kick out an error.
if (i === 0 || (i == 1 && ary[2] === '..') || ary[i - 1] === '..') {
continue;
} else if (i > 0) {
ary.splice(i - 1, 2);
i -= 2;
}
}
}
}

export function normalize(name, baseName){
var lastIndex,
normalizedBaseParts,
Expand All @@ -21,25 +44,29 @@ export function normalize(name, baseName){
return name.join('/');
}

function trimDots(ary) {
var i, part;
for (i = 0; i < ary.length; i++) {
part = ary[i];
if (part === '.') {
ary.splice(i, 1);
i -= 1;
} else if (part === '..') {
// If at the start, or previous value is still ..,
// keep them so that when converted to a path it may
// still work when converted to a path, even though
// as an ID it is less than ideal. In larger point
// releases, may be better to just kick out an error.
if (i === 0 || (i == 1 && ary[2] === '..') || ary[i - 1] === '..') {
continue;
} else if (i > 0) {
ary.splice(i - 1, 2);
i -= 2;
}
}
// Joins path segments. Preserves initial "/" and resolves ".." and "."
// Does not support using ".." to go above/outside the root.
// This means that join("foo", "../../bar") will not resolve to "../bar"
export function join(/* path segments */) {
// Split the inputs into a list of path commands.
var parts = [];
for (var i = 0, l = arguments.length; i < l; i++) {
parts = parts.concat(arguments[i].split("/"));
}
// Interpret the path commands to get the new resolved path.
var newParts = [];
for (i = 0, l = parts.length; i < l; i++) {
var part = parts[i];
// Remove leading and trailing slashes
// Also remove "." segments
if (!part || part === ".") continue;
// Interpret ".." to pop the last segment
if (part === "..") newParts.pop();
// Push new path segments.
else newParts.push(part);
}
// Preserve the initial slash if there was one.
if (parts[0] === "") newParts.unshift("");
// Turn back into a single string path.
return newParts.join("/") || (newParts.length ? "/" : ".");
}
7 changes: 7 additions & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## 0.2.0 (2014-12-16)


#### Features

* **join:** add a utility for joining paths ([9342f179](http://github.com/aurelia/path/commit/9342f179e548847f6c27d7e8a5b7fbb275f9c5b2))

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": "0.1.0",
"version": "0.2.0",
"description": "Utilities for path manipulation.",
"keywords": [
"aurelia",
Expand Down

0 comments on commit d1e83ff

Please sign in to comment.