trailsjs / trailpack-hapi

:package: Hapi.js Trailpack
MIT License
19 stars 9 forks source link

app.config.main.paths.www -> for Windows FIX #110

Closed imkarma closed 8 years ago

imkarma commented 8 years ago

On windows was error "Invalid path". Becouse plugin take window seperator "\". Now its fine :)

konstantinzolotarev commented 8 years ago

@imkarma not really sure that it's fixed. because staticDir might contain Windows path separator.

imkarma commented 8 years ago

@konstantinzolotarev now I use "trailpack-hapi": "git+https://github.com/imkarma/trailpack-hapi.git" and its work fine. Becouse if use old code I have

server.route({
        method: 'GET',
        path: '\static\{filename*}',
        ....
      })

but right syntaxis

server.route({
        method: 'GET',
        path: '/static/{filename*}',
        ....
      })

it's becouse Windows dir seperator '\' but we must have '/' like on unix os

imkarma commented 8 years ago

@scott-wyatt problem not with path. Promlem convert windowc path to string to applay http path. on windows we have \static{filename}, with path.normalize we will have somwthin like this \static\{filename}, but we need /static/{filename*} for http requests http://example.com/static/index.html for example

konstantinzolotarev commented 8 years ago

@imkarma Yep I know. I mean this code: const staticDir = path.relative(app.config.main.paths.root, app.config.main.paths.www) Could contain path something\some if

app.config.main.paths.root = 'something'
app.config.main.paths.www = 'some'

And your fix wouldn't work because it will include wrong staticDir

imkarma commented 8 years ago

@konstantinzolotarev Now i understend what you mean and add fix, I hope :)

imkarma commented 8 years ago

@konstantinzolotarev sorry can you look to this pull request again I add RegEx and now it must be cool :) Or geve feedback and i try rewritte if needed