Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path slash differences with Windows and Linux #896

Open
mcottontensor opened this issue Feb 19, 2024 · 2 comments
Open

Path slash differences with Windows and Linux #896

mcottontensor opened this issue Feb 19, 2024 · 2 comments

Comments

@mcottontensor
Copy link

On trying to get started with express-openapi on a Windows development environment, I got a nasty error about Unmatched ')' in a regular expression. Trying to hunt it down led me to fs-routes where files are being resolved.
Using path.resolve on Windows resolves paths with back slashes and on Linux, forward slashes. Code further down the line seems to assume all path separators are forward slashes. This means that some of the generated routes will become invalid and lead to broken code.
I changed the end of the fsRoutes() function to look like

.map(function (file) { return ({
            path: path.resolve(dir, file).replace(/\\/g, '/'),
            route: '/' + file.replace(options.indexFileRegExp, '').replace(/\\/g, '/')
        }); });

as a test and that fixed the issues I was having.

Is there a better way of handling this? I was a little surprised no one else had stumbled across this error so it leads me to believe I'm doing something wrong.

@renkei
Copy link

renkei commented Mar 22, 2024

I've already fixed this with PR877. Unfortunately, there is no maintenance for months by the author of this project... Hopefully this will change again in future...

@JPotterH
Copy link

I've been dealing with the same issue for a couple of weeks until I posted on StackOverflow and fortunately, @Narretz pointed me to this channel where finally my suspicion is confirmed.
Thnx!!

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

No branches or pull requests

3 participants