-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
implement URLPattern #785
base: main
Are you sure you want to change the base?
implement URLPattern #785
Conversation
89f46f0
to
02492e1
Compare
0ccd6d3
to
d2cd4f8
Compare
@anonrig Just to confirm... is this the spec? https://urlpattern.spec.whatwg.org |
Yes that's correct @lemire |
e51503f
to
524cb73
Compare
1a98cc9
to
18ef1a6
Compare
I don't particular mind, but please be aware that you are changing the coding convention. The C++ standard library uses all-lowercase with underscores names. You are using Camel case. If you merge this, it will mean that within the same library, we mix two conventions. |
380d57e
to
880e260
Compare
51690eb
to
010bc69
Compare
bf191ce
to
ce6c27d
Compare
ce6c27d
to
e7c580d
Compare
} | ||
|
||
template <url_pattern_encoding_callback F> | ||
Token* url_pattern_parser<F>::try_consume_modifier_token() { |
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.
You are returning a pointer to an instance of Token here. Who owns the Token instance? I recommend documenting it.
} | ||
|
||
template <url_pattern_encoding_callback F> | ||
Token* url_pattern_parser<F>::try_consume_regexp_or_wildcard_token( |
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.
I recommend documenting who owns the pointer to a Token instance here.
} | ||
|
||
template <url_pattern_encoding_callback F> | ||
Token* url_pattern_parser<F>::try_consume_token(token_type type) { |
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.
I recommend documenting who owns the pointer to a Token instance here.
|
||
// @see https://urlpattern.spec.whatwg.org/#pattern-parser | ||
template <url_pattern_encoding_callback F> | ||
class url_pattern_parser { |
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.
Instance of the template class url_pattern_parser appear to own tokens. We want to make sure that the token pointers never survive beyond the lifetime of their originator.
src/url_pattern_helpers.cpp
Outdated
// Let parser be a new pattern parser whose encoding callback is encoding | ||
// callback and segment wildcard regexp is the result of running generate a | ||
// segment wildcard regexp given options. | ||
auto parser = url_pattern_parser<F>( |
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.
The parser's scope is limited to this function, this means that the pointers to the token we generate within this function only lives for the duration of the function. We need to make sure that this is not a problem. It should be documented that no pointer to a token escapes this function.
f76e3ee
to
c3adedb
Compare
c3adedb
to
674c0bb
Compare
1e8c75f
to
8292933
Compare
8292933
to
3aad757
Compare
ccd1734
to
c0db9c8
Compare
This implements URLPattern from scratch. I'm adding
TODO: Optimization opportunity
notes in places I think an optimization can be done. The goal is to merge this once there is noTODO: Implement this
comments.TODOs
TODO: Implement this
occurrences (currently 4)url_pattern::match