[英]Zend_Controller_Router_Route_Regex is case insensitive
For those wondering why Zend_Controller_Router_Route_Regex
matches case-different routes, eg. 对于那些想知道为什么
Zend_Controller_Router_Route_Regex
匹配大小写不同的路由的人,例如。 hxxp://example.com/EN vs. hxxp://example.com/en, here's an explanation. hxxp://example.com/EN与hxxp://example.com/zh-CN,这是一个解释。
Zend_Controller_Router_Route_Regex
is implicitly case insensitive. Zend_Controller_Router_Route_Regex
隐式区分大小写。 It is set in Zend_Controller_Router_Route_Regex::match()
method. 在
Zend_Controller_Router_Route_Regex::match()
方法中设置。 This is the piece of code that sets PCRE_CASELESS
modifier: 这是设置
PCRE_CASELESS
修饰符的代码:
if (!$partial) {
$path = trim(urldecode($path), '/');
$regex = '#^' . $this->_regex . '$#i';
} else {
$regex = '#^' . $this->_regex . '#i';
}
I do not know if there is any way to suppress this behavior from inside of the regular expression. 我不知道是否有任何方法可以从正则表达式内部抑制这种行为。 Any ideas?
有任何想法吗?
您可以扩展Zend_Controller_Router_Route_Regex
并只写一个不同的match
方法,唯一的区别在于regex模式减去i
标志。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.