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

Support of wildcard in the beginning of the URL #152

Open
olignyf opened this issue Sep 16, 2016 · 2 comments
Open

Support of wildcard in the beginning of the URL #152

olignyf opened this issue Sep 16, 2016 · 2 comments

Comments

@olignyf
Copy link

olignyf commented Sep 16, 2016

Hi,

I'm halfway done in the Crossroads router+History.js implementation and I see something which seems not supported - or that I at least don't know how to do. It is to have a wildcard for the beginning of the route, or as a workaround configure a base-URL at the init stage.

Router.addRoute('*cities/{id}', function(cityId) { (...) } });

Because in dev mode my URL can be
http://localhost/dev/sandbox/home-panel/public/
http://localhost/dev/sandbox/home-panel/public/cities/2643339
etc.

And in production
domain.com
domain.com/cities/2643339
etc.

Thanks!

@sumitkm
Copy link

sumitkm commented Sep 16, 2016

Hi @olignyf
This usually isn't a problem. Routing works off the url fragment after top level domain. So if the top level domain changes it doesn't make a difference to the router. However in your application, if you want to see the full route somehow, you can use window.location.href.

Also if you inspect the state object returned from HistoryJS' adapter's getState(), you see all the URL components in it.

To test out how your router behaves with something other than localhost, you can put a host file entry pointing 127.0.0.1 to say dev.domain.local in your dev machine.

(edit the C:\windows\system32\drivers\etc\hosts file, you have to open it using elevated privileges)

dev.domain.local    127.0.0.1

Cheers

@olignyf
Copy link
Author

olignyf commented Sep 16, 2016

Oh but my problem is not with the domain name but with the URL fragment. If you take a look at the URL provided my website can run from a subdirectory which is what is not working.

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