Incorrect match when multiple urlMatch attributes are defined as regular expressions
ltm opened this issue · 0 comments
Stencil version:
ionic-docs@1.0.0
└── @stencil/router@1.0.1
I'm submitting a ... (check one with "x")
- bug report
- feature request
- support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://stencil-worldwide.slack.com
Current behavior:
If multiple <stencil-route-link>
elements define urlMatch
using regular expressions, only one of the elements will correctly match the URL.
Expected behavior:
Multiple <stencil-route-link>
elements should be able to define urlMatch
using regular expressions.
Steps to reproduce:
Define multiple <stencil-route-link>
elements with urlMatch
using regular expressions:
<stencil-route-link url="/docs/" urlMatch={[/^\/docs(?!\/(api|components|cli|native)).*$/]}>Guide</stencil-route-link>
<stencil-route-link url="/docs/appflow" urlMatch={[/^\/docs\/appflow(?!\/(tutorial)).*$/]}>Guide</stencil-route-link>
Notice that only one of the two elements will match its URL.
Related code:
The compilePath()
function uses JSON.stringify()
to generate a cache pattern, cachePattern
. If pattern
is a regular expression or an array of regular expressions, the cache pattern will contain a non-unique value such as "{}"
or "[{}]"
:
Other information:
Given the pattern [/^\/docs(?!\/(api|components|cli|native)).*$/]
the compilePath()
function generates the cache pattern "[{}]"
: