Merge pull request #10255 from jeffin143/fix-10247

fix: better handle absolute paths
This commit is contained in:
Tobias Koppers 2020-01-15 18:49:15 +01:00 committed by GitHub
commit 627510d7e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -25,8 +25,6 @@ module.exports = ajv =>
function callback(data) {
let passes = true;
const isExclamationMarkPresent = data.includes("!");
const isCorrectAbsoluteOrRelativePath =
expected === /^(?:[A-Za-z]:\\|\/)/.test(data);
if (isExclamationMarkPresent) {
callback.errors = [
@ -40,8 +38,12 @@ module.exports = ajv =>
];
passes = false;
}
if (!isCorrectAbsoluteOrRelativePath) {
// ?:[A-Za-z]:\\ - Windows absolute path
// \\\\ - Windows network absolute path
// \/ - Unix-like OS absolute path
const isCorrectAbsolutePath =
expected === /^(?:[A-Za-z]:\\|\\\\|\/)/.test(data);
if (!isCorrectAbsolutePath) {
callback.errors = [getErrorFor(expected, data, schema)];
passes = false;
}