Fix #357 - Path.resolve() should not crash with missing Path.relative()
This commit is contained in:
parent
f338991ace
commit
c85fa1851f
|
@ -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