Skip to content

Commit

Permalink
Allow dots in bin names (#7811)
Browse files Browse the repository at this point in the history
* Fixed bin regex

* Removed unsupported by Windows colon from bin regex

* Updated normalize-manifest tests

* Update fix.js

* Update actual.json

* Update normalize-manifest.js.snap

Co-authored-by: Maël Nison <nison.mael@gmail.com>
  • Loading branch information
valerybugakov and arcanis committed Jan 22, 2020
1 parent 1b334e6 commit af4c205
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
3 changes: 3 additions & 0 deletions __tests__/__snapshots__/normalize-manifest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ Array [

exports[`dangerous bin name: dangerous bin name 1`] = `
Array [
"foo: Invalid bin entry for \\".\\" (in \\"foo\\").",
"foo: Invalid bin entry for \\"..\\" (in \\"foo\\").",
"foo: Invalid bin entry for \\"/tmp/foo\\" (in \\"foo\\").",
"foo: Invalid bin entry for \\"../tmp/foo\\" (in \\"foo\\").",
"foo: Invalid bin entry for \\"tmp/../../foo\\" (in \\"foo\\").",
"foo: Invalid bin entry for \\"build:cli\\" (in \\"foo\\").",
"foo: No license field",
]
`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"name": "foo",
"version": "",
"bin": {
"/tmp/foo": "main.js",
"../tmp/foo": "main.js",
"tmp/../../foo": "main.js"
}
"name": "foo",
"version": "",
"bin": {
".": "main.js",
"..": "main.js",
"/tmp/foo": "main.js",
"../tmp/foo": "main.js",
"tmp/../../foo": "main.js",
"build:cli": "main.js",
"build.cli": "main.js"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"name": "foo",
"version": "",
"bin": {}
"name": "foo",
"version": "",
"bin": {
"build.cli": "main.js"
}
}
2 changes: 1 addition & 1 deletion src/util/normalize-manifest/fix.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const semver = require('semver');
const path = require('path');
const url = require('url');

const VALID_BIN_KEYS = /^[a-z0-9_-]+$/i;
const VALID_BIN_KEYS = /^(?!\.{0,2}$)[a-z0-9._-]+$/i;

const LICENSE_RENAMES: {[key: string]: ?string} = {
'MIT/X11': 'MIT',
Expand Down

0 comments on commit af4c205

Please sign in to comment.