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 international utf-8 chars in param values / names #38

Open
honzatrtik opened this issue Jan 5, 2015 · 4 comments
Open

Support international utf-8 chars in param values / names #38

honzatrtik opened this issue Jan 5, 2015 · 4 comments

Comments

@honzatrtik
Copy link

Hello!

international letter chars are not supported -

var Route = require('susanin').Route;
var route = Route('/<foo>/<bar>/<baz>');
console.log(route.match('/esc/rzy/aie')); // { foo: 'esc', bar: 'rzy', baz: 'aie' }
console.log(route.match('/ěšč/řžý/áíé')); // null

Using xregexp library (its unicode support - http://xregexp.com/plugins/#unicode) seems to be possible workaround.

@golyshevd
Copy link

+1

why parameter values are not [^\/]+?

https://github.com/nodules/susanin/blob/master/lib/route.js#L76

@kaero
Copy link
Contributor

kaero commented Jan 6, 2015

As for me, using the XRegExp library as a general solution for the matching is not suitable for the router which targeted to be fast. On first sight the better solution is to provide interface to setup custom matching functions – then you can use whatever you want to match routes.

@ruslankerimov
Copy link
Member

By following rfc3986 the list of allowed characters in URI is this.

I think there are three solutions:

  1. do nothing, because we can do like this;
  2. use [^\/]+;
  3. add % to regexp and decode values by decodeURIComponent, due to request to /ěšč/řžý/áí should be replaced to /%C4%9B%C5%A1%C4%8D/%C5%99%C5%BE%C3%BD/%C3%A1%C3%AD%C3%A9.

What do you think, which one is better?

@sbmaxx
Copy link

sbmaxx commented Mar 4, 2015

Maybe for now we add basic support for cyrillic like this:

var PARAM_VALUE_REGEXP_SOURCE = '[\\w\\-\\.~\u0400-\u04FF]+';

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

5 participants