From 88eef5d7d2fc9c18ae1027c37831d75d68edbcc3 Mon Sep 17 00:00:00 2001 From: Alex Brausewetter Date: Fri, 28 Feb 2020 14:36:16 +0100 Subject: [PATCH] Fix invalid regex in getWorkerUrl Fixes a typo introduced in #101 where the rendered regex was not escaped correctly. ``` $ npm run test ERROR in ../node_modules/monaco-editor/esm/vs/editor/editor.api.js (include-loader!../node_modules/monaco-editor/esm/vs/editor/editor.api.js) 9:15 Module parse failed: Invalid regular expression: /^((http:)|(https:)|(file:)|(/: Unterminated group (9:15) File was processed with these loaders: * ../out/loaders/include.js You may need an additional loader to handle the result of these loaders. | var pathPrefix = typeof __webpack_public_path__ === 'string' ? __webpack_public_path__ : ""; | var result = (pathPrefix ? stripTrailingSlash(pathPrefix) + '/' : '') + paths[label]; > if (/^((http:)|(https:)|(file:)|(//))/.test(result)) { | var currentUrl = String(window.location); | var currentOrigin = currentUrl.substr(0, currentUrl.length - window.location.hash.length - window.location.search.length - window.location.pathname.length); @ ./index.js 2:0-77 4:0-13 ``` Tested on local. --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index fa7d85f5..c2eeb08b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -197,7 +197,7 @@ function createLoaderRules(languages: IFeatureDefinition[], features: IFeatureDe getWorkerUrl: function (moduleId, label) { var pathPrefix = ${pathPrefix}; var result = (pathPrefix ? stripTrailingSlash(pathPrefix) + '/' : '') + paths[label]; - if (/^((http:)|(https:)|(file:)|(\/\/))/.test(result)) { + if (/^((http:)|(https:)|(file:)|(\\/\\/))/.test(result)) { var currentUrl = String(window.location); var currentOrigin = currentUrl.substr(0, currentUrl.length - window.location.hash.length - window.location.search.length - window.location.pathname.length); if (result.substring(0, currentOrigin.length) !== currentOrigin) {