From 3060440414e2e93ed63cd37bed0a08d52b0d6a11 Mon Sep 17 00:00:00 2001 From: Guillaume FORTAINE Date: Sun, 29 Jan 2023 22:07:15 +0100 Subject: [PATCH] fix(regex): allow spaces in path --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 479c13d..88e8baf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ const DIRNAME_POSIX_REGEX = /^((?:\.(?![^\/]))|(?:(?:\/?|)(?:[\s\S]*?)))(?:\/+?|)(?:(?:\.{1,2}|[^\/]+?|)(?:\.[^.\/]*|))(?:[\/]*)$/; const DIRNAME_WIN32_REGEX = /^((?:\.(?![^\\]))|(?:(?:\\?|)(?:[\s\S]*?)))(?:\\+?|)(?:(?:\.{1,2}|[^\\]+?|)(?:\.[^.\\]*|))(?:[\\]*)$/; -const EXTRACT_PATH_REGEX = /@?(?[file:\/\/]?[^\(\s]+):[0-9]+:[0-9]+/; +const EXTRACT_PATH_REGEX = /@?(?[file:\/\/]+?[^\(]+):[0-9]+:[0-9]+/; const WIN_POSIX_DRIVE_REGEX = /^\/[A-Z]:\/*/; const pathDirname = (path: string) => { @@ -35,7 +35,7 @@ const getPathFromErrorStack = () => { } if (initiator) { - path = EXTRACT_PATH_REGEX.exec(initiator)?.groups?.path || ''; + path = decodeURI(EXTRACT_PATH_REGEX.exec(initiator)?.groups?.path || ''); } if(!initiator || !path) {