-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add trailing slash to regular expressions #22
Conversation
@@ -30,7 +30,7 @@ const generateManifest = ({ bundles = [], declarations = [], functions }: Genera | |||
return | |||
} | |||
|
|||
const pattern = 'pattern' in declaration ? new RegExp(declaration.pattern) : globToRegExp(declaration.path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait what is this 'pattern' in declaration
? is that the same as declaration?.pattern
? I almost never see in
used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but since declaration
is a union type (DeclarationWithPath
or DeclarationWithPattern
) and the pattern
property only exists in one of them, the in
allows us to disambiguate. So if you do:
if ('pattern' in declaration) {
// From this point on you know that `declaration` is of type
// `DeclarationWithPattern` and so does the TypeScript compiler.
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test updates look kosher to me
Do we need to worry about the case where a customer wants different behavior for /path and /path/ ? I haven't seen requests for that, just wanted to mention it as a potential cost of this implementation. |
Which problem is this pull request solving?
This PR changes the regular expressions generated from a
path
declaration so that they contain an optional trailing slash.So
/foo
will yield^/foo/?$
instead of^/foo$
.