-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
This issue turned up here
I spoke to @TylorS and we thought giving the use of /$ would help, I wrote tests but was unable to implement the required use as I can only get one test or the other to pass never both.
it('should match a root base path when using /$', () => {
const {path, value} = switchPath('/abc', {
'/$': 123,
'/home': 456,
'/bar': 789,
'*': 'Route not defined'
});
expect(path).to.be.equal('/abc');
expect(value).to.be.equal('Route not defined');
});
it('should still match a notFound pattern when using /$', () => {
const {path, value} = switchPath('/', {
'/$': 123,
'/home': 456,
'/bar': 789,
'*': 'Route not defined'
});
expect(path).to.be.equal('/');
expect(value).to.be.equal(123);
});
and here is how far I got :
traverseRoutes(routes, function matchPattern(pattern) {
if (pattern === `/$`) {
matchedPath = pattern // matchedPath = `/`
// it needs to be one or the other dependent on visited route falls in * or `/`
matchedValue = routes[pattern]
} else if (sourcePath.search(pattern) === 0 && betterMatch(pattern, matchedPath)) {
matchedPath = pattern
matchedValue = routes[pattern]
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels