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

Cannot load paths on windows machines #3

Closed
punmechanic opened this issue Jun 6, 2015 · 4 comments
Closed

Cannot load paths on windows machines #3

punmechanic opened this issue Jun 6, 2015 · 4 comments

Comments

@punmechanic
Copy link

See zedgu/surface#5

When paths are resolved on windows machines they are resolved to c:/path/to/resource, rather than /path/to/resource (or /c/path/to/resource). The path loading algorithm in ovenware uses regex and falls flat on windows paths:

c:\loluk\node_modules\surface\node_modules\koa-ovenware\node_modules\ovenware\lib\loader.js:38
        paths[file.replace(new RegExp('^' + path.join(path.resolve(root), '/')
                           ^
SyntaxError: Invalid regular expression: /^c:\loluk\lib\controllers\/: \ at end of pattern
    at new RegExp (native)
    at c:\loluk\node_modules\surface\node_modules\koa-ovenware\node_modules\ovenware\lib\loader.js:38:28
    at Array.forEach (native)
    at loadfiles (c:\loluk\node_modules\surface\node_modules\koa-ovenware\node_modules\ovenware\lib\loader.js:34:9)
    at module.exports (c:\loluk\node_modules\surface\node_modules\koa-ovenware\node_modules\ovenware\lib\loader.js:5:15)
    at new Ovenware (c:\loluk\node_modules\surface\node_modules\koa-ovenware\node_modules\ovenware\lib\ovenware.js:47:16)
    at Ovenware (c:\loluk\node_modules\surface\node_modules\koa-ovenware\node_modules\ovenware\lib\ovenware.js:42:12)
    at Surface.surface.load (c:\loluk\node_modules\surface\lib\surface.js:118:13)
    at Surface.surface.middleware (c:\loluk\node_modules\surface\lib\surface.js:168:8)
    at new Surface (c:\loluk\node_modules\surface\lib\surface.js:84:8)
@punmechanic
Copy link
Author

After a poke around in your source code this appears to be due to your use of path to resolve url paths. path.join/path.resolve both use path.sep - on windows, this may be \. As a result a lot of your regex paths are being escaped. In your loader you can safely replace \ with / as long as you remember to remove the leading slash, but you can't do this in ovenware because you have regex patterns in your routes which will conflict with \.

You should instead use something like url-join. I attempted to do it myself, but unfortunately I seem to break the /items/:id routes and couldn't work out why.

If you could get this fixed I would very grateful; your library is very useful in eliminating boiler plate (especially surface), but I simply can't use it otherwise.

@zedgu
Copy link
Owner

zedgu commented Jun 8, 2015

Duplicate of #1
I'll setup a windows and try to fix this.

zedgu added a commit that referenced this issue Jun 8, 2015
@zedgu
Copy link
Owner

zedgu commented Jun 8, 2015

I just published v0.2.0,it fixed windows issues i think.

@zedgu zedgu closed this as completed Jun 8, 2015
@punmechanic
Copy link
Author

Thanks, I'll give it a go when I get home from the office.

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

2 participants