Fix optional laravel route parameters
Update laravel-routes.js to fix having optional route parameters
Fix for optional parameters in the laravel route "/teams/{team}/dashboard/{style?}"
uri = uri.replace(
new RegExp(`{${parameter}[^}]*}`),
parameters[parameter]
);
In this example, the regular expression /{style[^}]*}/ will match {style} or {style?} in the string variable.
The [^}] part of the regular expression matches any character that is not a closing curly bracket (}), and the * character matches zero or more of the preceding character or group. This allows the regular expression to match any characters between the {style and } parts of the string.
I just ran into this myself, but the regex I came up with is a little different. The problem I see with the one proposed here is that it will also match for example {styleName}. Here's my version, which only adds support for an optional ? after the parameter name: https://github.com/laracasts/cypress/pull/83