Comments (10)
It should be more than that IMHO. Anything that is not a control character should be usable maybe?
from router.
I see that Laravel uses '/\{(.*?)\}/'
as the pattern to extract parameters.
I'll gladly accept a PR containing the change (+ accompanying tests) :-)
from router.
I propose to change the line 341-344
$route['pattern'] = preg_replace('/{([A-Za-z]*?)}/', '(\w+)', $route['pattern']);
if (preg_match_all('#^'.$route['pattern'].'$#', $uri, $matches, PREG_OFFSET_CAPTURE)) {
to
$route['pattern'] = preg_replace('/(?![\]p){([A-Za-z]*?)}/', '(\w+)', $route['pattern']);
if (preg_match_all('#^'.$route['pattern'].'$#u', $uri, $matches, PREG_OFFSET_CAPTURE)) {
So that the router allow all unicode characters character class \p{L} according to https://stackoverflow.com/a/38938931
from router.
Apparently $_SERVER["REQUEST_URI"] encodes non-latin and symbols to RFC-3986 and needs to be decoded before the route matching.
from router.
I've just pushed some things to master
. Looking forward to your feedback.
The problem here was twofold:
- Support for Cyrillic/astral/etc. Symbols in route pattern values (e.g. make it so that
/hello/π©
matches the route pattern/hello/{name}
) - Support for Cyrillic/astral/etc. Symbols in route placeholder names (e.g. make it so that
/hello/bramus
matches the route pattern/hello/{ΠΈΠΌΠ΅}
)
I've done two separate commits to tackle this:
- Support for Cyrillic/astral/etc. Symbols in route pattern values: 0f4733d
- Support for Cyrillic/astral/etc. Symbols in route placeholder names: ae0db20
Feel free to test this from dev-master
(Circle CI says all is fine). If well received I'll tag it as a new release.
from router.
I might have misunderstood this issue. I thought it was about supporting unicode characters on the route itself.
My bad.
from router.
@fscchan Yeah, that was my first impression too. Took me a while to notice that the original poster was adjusting the regex part for the placeholders (e.g. {var}
in a route pattern).
While I was at it, I thought I'd just fix both cases ;)
from router.
FYI: Version 1.4 got tagged and released.
from router.
Yes! That worked.
Just one more thing: somewhere in getCurrentUri function the text should be urldecode-ed
from router.
Will take a look into it.
from router.
Related Issues (20)
- Any HTTP code handling? HOT 3
- Multilingual default route without lang
- Generating URLs HOT 1
- Form submits a GET request without a submit-button HOT 1
- um... controller blank page HOT 1
- how to run php file with command .for example: php index.php Home index HOT 1
- How can i serve the static folder using Router? HOT 1
- $match arrgument not being used anywhere
- after router middleware not keeping states?
- How can I setup this middleware? HOT 1
- router in subfolder HOT 2
- There is no Cache funciton! so Please Add Caching Feature! HOT 1
- 404 error executing more than twice
- No executing middleware HOT 2
- I have uploaded my system that works with this router to the hosting, and it's not functioning. HOT 1
- Post values not coming
- Accessors and named routes
- How to do the following HOT 4
- Lazy loading class
- Undefined array key warning HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from router.