Skip to content

Escape windows path sep for regex - #249

Open
tf2spi wants to merge 1 commit into
sourcegraph:scipfrom
tf2spi:regex-windows-path-sep-escape
Open

tf2spi wants to merge 1 commit into
sourcegraph:scipfrom
tf2spi:regex-windows-path-sep-escape

Conversation

@tf2spi

@tf2spi tf2spi commented Nov 18, 2026 •

Copy link
Copy Markdown

When using scip-python on Windows, I get an error like below because '\', Windows path separator, is used for escaping characters and must be escaped itself to interpret it as a literal '\'

>scip-python
C:\Users\Delta\AppData\Local\Author Software\nvm\installs\v26.13.0\node_modules\@sourcegraph\scip-python\dist\scip-python\src\virtualenv\PythonEnvironment.ts:4
const pathSepRegex = new RegExp(path.sep, 'g');
                     ^

SyntaxError: Invalid regular expression: /\/g: \ at end of pattern
    at new RegExp (<anonymous>)
    at Object.call (C:\Users\Delta\AppData\Local\Author Software\nvm\installs\v26.13.0\node_modules\@sourcegraph\scip-python\dist\scip-python\src\virtualenv\PythonEnvironment.ts:4:22)
    at r (C:\Users\Delta\AppData\Local\Author Software\nvm\installs\v26.13.0\node_modules\@sourcegraph\scip-python\dist\webpack\bootstrap:19:32)
    at Object.call (C:\Users\Delta\AppData\Local\Author Software\nvm\installs\v26.13.0\node_modules\@sourcegraph\scip-python\dist\scip-python\src\virtualenv\environment.ts:6:1)
    at r (C:\Users\Delta\AppData\Local\Author Software\nvm\installs\v26.13.0\node_modules\@sourcegraph\scip-python\dist\webpack\bootstrap:19:32)
    at Object.call (C:\Users\Delta\AppData\Local\Author Software\nvm\installs\v26.13.0\node_modules\@sourcegraph\scip-python\dist\scip-python\src\indexer.ts:18:1)
    at r (C:\Users\Delta\AppData\Local\Author Software\nvm\installs\v26.13.0\node_modules\@sourcegraph\scip-python\dist\webpack\bootstrap:19:32)
    at Object.call (C:\Users\Delta\AppData\Local\Author Software\nvm\installs\v26.13.0\node_modules\@sourcegraph\scip-python\dist\scip-python\src\main-impl.ts:10:1)
    at r (C:\Users\Delta\AppData\Local\Author Software\nvm\installs\v26.13.0\node_modules\@sourcegraph\scip-python\dist\webpack\bootstrap:19:32)
    at Object.6608 (C:\Users\Delta\AppData\Local\Author Software\nvm\installs\v26.13.0\node_modules\@sourcegraph\scip-python\dist\scip-python\src\main.ts:1:1)

Node.js v26.13.0

This PR is a very simple change to escape '\' as '\\' specifically for the path separator when creating the regex

P.S. Hi, this is my first PR to the project, thank you for maintaining scip-python! It's really neat, easy-to-use, and helpful for indexing my python codebases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant