New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More →

urltools

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

urltools - npm Package Compare versions

Comparing version

to
0.4.1

@@ -140,3 +140,10 @@ var Url = require('url'),

fileUrl = fileUrl.replace(/[?#].*$/, ''); // Strip query string and fragment identifier
return decodeURI(fileUrl).substr((process.platform === 'win32' ? 'file:///' : 'file://').length).replace(/[#\?].*$/, '');
var fsPath = decodeURI(fileUrl).substr('file://'.length).replace(/[#\?].*$/, '');
if (process.platform === 'win32') {
fsPath = fsPath.replace(/^\/([^/]+)/, function ($0, encodedDriveLetter) {
return decodeURIComponent(encodedDriveLetter);
});
}
return fsPath;
};

@@ -143,0 +150,0 @@

@@ -5,3 +5,3 @@ {

"description": "URL tooling for assetgraph",
"version": "0.4.0",
"version": "0.4.1",
"license": "BSD-2-Clause",

@@ -34,5 +34,5 @@ "maintainers": [

"lint": "jshint .",
"test": "vows test --spec",
"test": "mocha",
"travis": "npm run test && npm run lint"
}
}

@@ -0,1 +1,2 @@

/*global describe, it*/
var expect = require('unexpected');

@@ -201,1 +202,21 @@ var urlTools = require('../lib');

});
describe('on Windows', function () {
var originalPlatform = process.platform;
beforeEach(function () {
Object.defineProperty(process, 'platform', { value: 'win32' });
});
afterEach(function () {
Object.defineProperty(process, 'platform', { value: originalPlatform });
});
describe('#urlOrFsPathToUrl', function () {
it('should reinstate the drive letter in decoded form', function () {
expect(
urlTools.fileUrlToFsPath('file:///C%3A/foo/bar%20quux.png'),
'to equal',
'C:/foo/bar quux.png'
);
});
});
});