Skip to content

Commit

Permalink
Fix behavior of file rebasing when file starts with "file:./"
Browse files Browse the repository at this point in the history
Relative files that are located in the same directory as the
package.json, e.g. `"file:./foo.tgz"`, were not being rebased correctly
by `rebaseFileReferences` due to a bad regular expression. The regex has
been fixed in this commit.
  • Loading branch information
talbenari1 authored and j0k3r committed Jul 29, 2020
1 parent a114524 commit 9f11154
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/packExternalModules.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const isBuiltinModule = require('is-builtin-module');
const Packagers = require('./packagers');

function rebaseFileReferences(pathToPackageRoot, moduleVersion) {
if (/^(?:file:[^/]{2}|\.\/|\.\.\/)/.test(moduleVersion)) {
if (/^(file:[^/]|\.\/|\.\.\/)/.test(moduleVersion)) {
const filePath = _.replace(moduleVersion, /^file:/, '');
return _.replace(
`${_.startsWith(moduleVersion, 'file:') ? 'file:' : ''}${pathToPackageRoot}/${filePath}`,
Expand Down Expand Up @@ -446,4 +446,3 @@ module.exports = {
});
}
};

0 comments on commit 9f11154

Please sign in to comment.