Merge pull request #359 from humphd/issue357
Fix #357 - Path.resolve() should not crash with missing Path.relative()
This commit is contained in:
commit
6549a98b6a
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,4 @@
|
|||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Path=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
|
||||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Path = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -121,8 +121,8 @@ function join() {
|
|||
|
||||
// path.relative(from, to)
|
||||
function relative(from, to) {
|
||||
from = exports.resolve(from).substr(1);
|
||||
to = exports.resolve(to).substr(1);
|
||||
from = resolve(from).substr(1);
|
||||
to = resolve(to).substr(1);
|
||||
|
||||
function trim(arr) {
|
||||
var start = 0;
|
||||
|
@ -239,6 +239,5 @@ module.exports = {
|
|||
removeTrailing: removeTrailing
|
||||
};
|
||||
|
||||
},{}]},{},[1])
|
||||
(1)
|
||||
},{}]},{},[1])(1)
|
||||
});
|
|
@ -1,2 +1,2 @@
|
|||
/*! filer 0.0.41 2015-06-01 */
|
||||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Path=t()}}(function(){return function t(e,n,r){function i(a,s){if(!n[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);throw Error("Cannot find module '"+a+"'")}var c=n[a]={exports:{}};e[a][0].call(c.exports,function(t){var n=e[a][1][t];return i(n?n:t)},c,c.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;r.length>a;a++)i(r[a]);return i}({1:[function(t,e,n){function r(t,e){for(var n=0,r=t.length-1;r>=0;r--){var i=t[r];"."===i?t.splice(r,1):".."===i?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}function i(){for(var t="",e=!1,n=arguments.length-1;n>=-1&&!e;n--){var i=n>=0?arguments[n]:"/";"string"==typeof i&&i&&(t=i+"/"+t,e="/"===i.charAt(0))}return t=r(t.split("/").filter(function(t){return!!t}),!e).join("/"),(e?"/":"")+t||"."}function o(t){var e="/"===t.charAt(0);return"/"===t.substr(-1),t=r(t.split("/").filter(function(t){return!!t}),!e).join("/"),t||e||(t="."),(e?"/":"")+t}function a(){var t=Array.prototype.slice.call(arguments,0);return o(t.filter(function(t){return t&&"string"==typeof t}).join("/"))}function s(t,e){function r(t){for(var e=0;t.length>e&&""===t[e];e++);for(var n=t.length-1;n>=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=n.resolve(t).substr(1),e=n.resolve(e).substr(1);for(var i=r(t.split("/")),o=r(e.split("/")),a=Math.min(i.length,o.length),s=a,u=0;a>u;u++)if(i[u]!==o[u]){s=u;break}for(var c=[],u=s;i.length>u;u++)c.push("..");return c=c.concat(o.slice(s)),c.join("/")}function u(t){var e=v(t),n=e[0],r=e[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."}function c(t,e){var n=v(t)[2];return e&&n.substr(-1*e.length)===e&&(n=n.substr(0,n.length-e.length)),""===n?"/":n}function f(t){return v(t)[3]}function l(t){return"/"===t.charAt(0)?!0:!1}function h(t){return-1!==(""+t).indexOf("\0")?!0:!1}function p(t){return t.replace(/\/*$/,"/")}function d(t){return t=t.replace(/\/*$/,""),""===t?"/":t}var g=/^(\/?)([\s\S]+\/(?!$)|\/)?((?:\.{1,2}$|[\s\S]+?)?(\.[^.\/]*)?)$/,v=function(t){var e=g.exec(t);return[e[1]||"",e[2]||"",e[3]||"",e[4]||""]};e.exports={normalize:o,resolve:i,join:a,relative:s,sep:"/",delimiter:":",dirname:u,basename:c,extname:f,isAbsolute:l,isNull:h,addTrailing:p,removeTrailing:d}},{}]},{},[1])(1)});
|
||||
/*! filer 0.0.41 2015-06-29 */
|
||||
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.Path=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){function d(a,b){for(var c=0,d=a.length-1;d>=0;d--){var e=a[d];"."===e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}function e(){for(var a="",b=!1,c=arguments.length-1;c>=-1&&!b;c--){var e=c>=0?arguments[c]:"/";"string"==typeof e&&e&&(a=e+"/"+a,b="/"===e.charAt(0))}return a=d(a.split("/").filter(function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."}function f(a){var b="/"===a.charAt(0);"/"===a.substr(-1);return a=d(a.split("/").filter(function(a){return!!a}),!b).join("/"),a||b||(a="."),(b?"/":"")+a}function g(){var a=Array.prototype.slice.call(arguments,0);return f(a.filter(function(a,b){return a&&"string"==typeof a}).join("/"))}function h(a,b){function c(a){for(var b=0;b<a.length&&""===a[b];b++);for(var c=a.length-1;c>=0&&""===a[c];c--);return b>c?[]:a.slice(b,c-b+1)}a=e(a).substr(1),b=e(b).substr(1);for(var d=c(a.split("/")),f=c(b.split("/")),g=Math.min(d.length,f.length),h=g,i=0;g>i;i++)if(d[i]!==f[i]){h=i;break}for(var j=[],i=h;i<d.length;i++)j.push("..");return j=j.concat(f.slice(h)),j.join("/")}function i(a){var b=q(a),c=b[0],d=b[1];return c||d?(d&&(d=d.substr(0,d.length-1)),c+d):"."}function j(a,b){var c=q(a)[2];return b&&c.substr(-1*b.length)===b&&(c=c.substr(0,c.length-b.length)),""===c?"/":c}function k(a){return q(a)[3]}function l(a){return"/"===a.charAt(0)?!0:!1}function m(a){return-1!==(""+a).indexOf("\x00")?!0:!1}function n(a){return a.replace(/\/*$/,"/")}function o(a){return a=a.replace(/\/*$/,""),""===a?"/":a}var p=/^(\/?)([\s\S]+\/(?!$)|\/)?((?:\.{1,2}$|[\s\S]+?)?(\.[^.\/]*)?)$/,q=function(a){var b=p.exec(a);return[b[1]||"",b[2]||"",b[3]||"",b[4]||""]};b.exports={normalize:f,resolve:e,join:g,relative:h,sep:"/",delimiter:":",dirname:i,basename:j,extname:k,isAbsolute:l,isNull:m,addTrailing:n,removeTrailing:o}},{}]},{},[1])(1)});
|
20
gruntfile.js
20
gruntfile.js
|
@ -65,9 +65,7 @@ module.exports = function(grunt) {
|
|||
options: {
|
||||
browserifyOptions: {
|
||||
commondir: false,
|
||||
builtins: ["buffer", "path", "url", "punycode", "querystring"]
|
||||
},
|
||||
bundleOptions: {
|
||||
builtins: ["buffer", "path", "url", "punycode", "querystring"],
|
||||
insertGlobalVars: {
|
||||
// This ensures that process won't be defined, since
|
||||
// browserify will do so automatically if any globals
|
||||
|
@ -87,9 +85,7 @@ module.exports = function(grunt) {
|
|||
options: {
|
||||
browserifyOptions: {
|
||||
commondir: false,
|
||||
builtins: ["buffer", "path", "url", "punycode", "querystring"]
|
||||
},
|
||||
bundleOptions: {
|
||||
builtins: ["buffer", "path", "url", "punycode", "querystring"],
|
||||
insertGlobalVars: {
|
||||
// This ensures that process won't be defined, since
|
||||
// browserify will do so automatically if any globals
|
||||
|
@ -108,9 +104,7 @@ module.exports = function(grunt) {
|
|||
options: {
|
||||
browserifyOptions: {
|
||||
commondir: false,
|
||||
builtins: ["buffer", "path", "url", "punycode", "querystring"]
|
||||
},
|
||||
bundleOptions: {
|
||||
builtins: ["buffer", "path", "url", "punycode", "querystring"],
|
||||
insertGlobalVars: {
|
||||
// This ensures that process won't be defined, since
|
||||
// browserify will do so automatically if any globals
|
||||
|
@ -129,9 +123,7 @@ module.exports = function(grunt) {
|
|||
options: {
|
||||
browserifyOptions: {
|
||||
commondir: false,
|
||||
builtins: ["buffer", "path", "url", "punycode", "querystring"]
|
||||
},
|
||||
bundleOptions: {
|
||||
builtins: ["buffer", "path", "url", "punycode", "querystring"],
|
||||
insertGlobalVars: {
|
||||
// This ensures that process won't be defined, since
|
||||
// browserify will do so automatically if any globals
|
||||
|
@ -150,7 +142,7 @@ module.exports = function(grunt) {
|
|||
src: "./src/path.js",
|
||||
dest: "./dist/path.js",
|
||||
options: {
|
||||
bundleOptions: {
|
||||
browserifyOptions: {
|
||||
standalone: 'Path'
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +151,7 @@ module.exports = function(grunt) {
|
|||
src: "./src/buffer.js",
|
||||
dest: "./dist/buffer.js",
|
||||
options: {
|
||||
bundleOptions: {
|
||||
browserifyOptions: {
|
||||
standalone: 'FilerBuffer'
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,14 +32,14 @@
|
|||
"chai": "~1.9.1",
|
||||
"grunt": "~0.4.0",
|
||||
"grunt-banner": "^0.2.3",
|
||||
"grunt-browserify": "^2.1.0",
|
||||
"grunt-browserify": "^3.8.0",
|
||||
"grunt-bump": "0.0.13",
|
||||
"grunt-contrib-clean": "~0.4.0",
|
||||
"grunt-contrib-compress": "~0.4.1",
|
||||
"grunt-contrib-concat": "~0.1.3",
|
||||
"grunt-contrib-connect": "^0.7.1",
|
||||
"grunt-contrib-connect": "^0.10.1",
|
||||
"grunt-contrib-jshint": "~0.7.1",
|
||||
"grunt-contrib-uglify": "~0.1.2",
|
||||
"grunt-contrib-uglify": "^0.9.1",
|
||||
"grunt-contrib-watch": "~0.3.1",
|
||||
"grunt-git": "0.3.3",
|
||||
"grunt-npm": "git://github.com/sedge/grunt-npm.git#branchcheck",
|
||||
|
|
|
@ -120,8 +120,8 @@ function join() {
|
|||
|
||||
// path.relative(from, to)
|
||||
function relative(from, to) {
|
||||
from = exports.resolve(from).substr(1);
|
||||
to = exports.resolve(to).substr(1);
|
||||
from = resolve(from).substr(1);
|
||||
to = resolve(to).substr(1);
|
||||
|
||||
function trim(arr) {
|
||||
var start = 0;
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
var Path = require('../..').Path;
|
||||
var expect = require('chai').expect;
|
||||
|
||||
describe('Path.resolve does not work, issue357', function() {
|
||||
it('Path.relative() should not crash', function() {
|
||||
expect(Path.relative("/mydir", "/mydir/file")).to.equal("file");
|
||||
|
||||
// https://nodejs.org/api/path.html#path_path_relative_from_to
|
||||
expect(Path.relative("/data/orandea/test/aaa", "/data/orandea/impl/bbb")).to.equal("../../impl/bbb");
|
||||
});
|
||||
|
||||
it('Path.resolve() should work as expectedh', function() {
|
||||
// https://nodejs.org/api/path.html#path_path_resolve_from_to
|
||||
expect(Path.resolve('/foo/bar', './baz')).to.equal('/foo/bar/baz');
|
||||
expect(Path.resolve('/foo/bar', '/tmp/file/')).to.equal('/tmp/file');
|
||||
});
|
||||
});
|
|
@ -76,3 +76,4 @@ require("./bugs/issue258.js");
|
|||
require("./bugs/issue267.js");
|
||||
require("./bugs/issue270.js");
|
||||
require("./bugs/rename-dir-trailing-slash.js");
|
||||
require("./bugs/issue357.js");
|
||||
|
|
Loading…
Reference in New Issue