-
-
Notifications
You must be signed in to change notification settings - Fork 428
Error when using route with multiple parameters in single segment #547
Comments
I think this might be fixed with something as simple as a non-greedy wildcard here. |
Changing that regex to |
A few days ago I looked into what it would take to make rest parameters work (#545), and supporting multiple parameters in a single segment will affect that patch too, since it’ll need to keep track of which group/s of the regexp needs to be split on slashes. |
Here's what I have currently for function get_parts(part: string): Part[] {
const parts = [];
let state = 0;
let content = '';
let qualifier;
for (let i = 0; i < part.length; i++) {
const char = part[i];
const next = part[i + 1];
if (state === 0) {
if (char === '[') {
if (content) {
parts.push({ content, dynamic: false, qualifier: null });
}
state = 1;
content = '';
} else {
content += char;
}
} else if (state === 1) {
if (char === ']') {
if (content) {
parts.push({ content, dynamic: true, qualifier: null });
}
state = 0;
content = '';
} else if (char === '(') {
state = 2;
qualifier = '';
} else {
content += char;
}
} else if (state === 2) {
if (char === ')' && next === ']') {
parts.push({ content, dynamic: true, qualifier });
state = 0;
content = '';
i += 1;
} else {
qualifier += char;
}
}
}
if (state) {
throw new Error('this is bad');
}
if (content) {
parts.push({ content, dynamic: false, qualifier: null });
}
return parts;
} I don't know whether this is heading in the correct direction or not. I think it might be? There is other stuff that still needs to happen, but having this handled in a more parser-y way rather than with regexes feels saner. |
This has been finally fixed in 0.27.13 - thanks @JohnPeel! |
Does this changes somehow affect the route file names? I don't understand, cause after update from 0.27.10 to 0.27.13 some of routes in my app considered as not found routes? |
Can you give an example route? The only extra condition this applies is having slugs next to each other, but that would have already been invalid before the update. |
This issue can be reproduced by creating a route such as
routes/blah.[slug].[id].html
which results in an error like this one:The text was updated successfully, but these errors were encountered: