You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a new state is registered with the url attribute, a UrlMatcher is created for it, which is used to find the correct state whenever the location changes. The behaviour of UrlMatcher is controlled by the $urlMatcherFactoryProvider, which has two configurable defaults: strictMode and caseInsensitive. Whenever a new UrlMatcher is created via $urlMatcherFactory.compile, these defaults are applied. Therefore, if you set caseInsensitive to true, the URL matching will be case insensitive for all future matchers...
However, the behaviour of $state doesn't obey these defaults, since it almost never creates new UrlMatchers via compile, and instead uses UrlMatcher.concat, which (incorrectly?) ignores the default config specified by $urlMatcherFactory. Therefore, if you configure $urlMatcherFactory to use different defaults (e.g. caseInsensitive(true), strictMode(false)), it makes no difference: all your $state definitions end up using UrlMatchers that ignored the configured defaults.
Reproduction & Plunkr
There is a workaround: states with an absolute URL (one that starts with "^") use compile instead of concat, which brings in the default config correctly. Therefore, if you define three states like below, the 'home.concat' state doesn't match case-insensitively, whereas 'home.absolute' does!
I'd like to use the strictMode(false) behaviour to support trailing slashes in URLs, instead of specifying the other workaround of modifying the URL via a rule (which is in the FAQ). I need trailing slash support to keep both IE9 and modern browsers happy, and feel like this would be the cleanest approach.
Fix
I believe the best fix for this would be to remove UrlMatcher.concat and instead define $urlMatcherFactory.concat which does the same thing, except uses the default config instead. All existing uses of UrlMatcher.concat would be replaced with this.
I'm happy to put together a PR, if you guys think it makes sense. Thanks!
The text was updated successfully, but these errors were encountered:
Issue
When a new state is registered with the
url
attribute, aUrlMatcher
is created for it, which is used to find the correct state whenever the location changes. The behaviour ofUrlMatcher
is controlled by the$urlMatcherFactoryProvider
, which has two configurable defaults:strictMode
andcaseInsensitive
. Whenever a newUrlMatcher
is created via$urlMatcherFactory.compile
, these defaults are applied. Therefore, if you setcaseInsensitive
totrue
, the URL matching will be case insensitive for all future matchers...However, the behaviour of
$state
doesn't obey these defaults, since it almost never creates newUrlMatchers
viacompile
, and instead usesUrlMatcher.concat
, which (incorrectly?) ignores the default config specified by$urlMatcherFactory
. Therefore, if you configure$urlMatcherFactory
to use different defaults (e.g.caseInsensitive(true)
,strictMode(false)
), it makes no difference: all your$state
definitions end up usingUrlMatchers
that ignored the configured defaults.Reproduction & Plunkr
There is a workaround: states with an absolute URL (one that starts with "^") use
compile
instead ofconcat
, which brings in the default config correctly. Therefore, if you define three states like below, the 'home.concat' state doesn't match case-insensitively, whereas 'home.absolute' does!You can try this out in this Plunkr: http://plnkr.co/edit/lDz2zIIchWqkSgHdyx9y?p=preview
Why?
I'd like to use the
strictMode(false)
behaviour to support trailing slashes in URLs, instead of specifying the other workaround of modifying the URL via a rule (which is in the FAQ). I need trailing slash support to keep both IE9 and modern browsers happy, and feel like this would be the cleanest approach.Fix
I believe the best fix for this would be to remove
UrlMatcher.concat
and instead define$urlMatcherFactory.concat
which does the same thing, except uses the default config instead. All existing uses ofUrlMatcher.concat
would be replaced with this.I'm happy to put together a PR, if you guys think it makes sense. Thanks!
The text was updated successfully, but these errors were encountered: