-
Notifications
You must be signed in to change notification settings - Fork 23
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
Optional wildcard groups inconsistent with path-to-regexp behavior #162
Comments
I agree this behavior does not seem correct. Let me look into it. |
I think this is coming from default regexp behavior. This: /(.*)/.exec('')[1] Evaluates to the empty string. I'll have to see what path-to-regexp is doing to get it to be undefined. |
@wanderview but that's not the pattern it should evaluate to, right? It should be: /(?:\/(.*))?/.exec('')[1] // prints undefined |
Right, I see the regexp is different and urlpattern is using the same regexp. I'm still trying to figure out where the empty string is coming in. |
At least part of the problem here is urlpattern uses |
@wanderview your comment just made me realize that the scope of this bug is actually way larger than I thought! It doesn't just apply to optional wildcards but also optional variables: new URLPattern({pathname: '/a/:id?/b'}).exec({pathname: '/a/b'}).pathname.groups prints: |
Yea, this is a good catch. Thanks for filing the issue! This will change a significant number of test results I think, but I think its worth it. |
The other half of this is that chromium converts the null So I need to fix the implementation and the spec. |
FYI @lucacasonato. When this lands it will likely be a large number of tests changed. |
@wanderview Instead of making it But generally in favor 👍 |
@domenic mentioned that possibility, but we want to add the record with an |
This addresses the issues raised in: whatwg/urlpattern#162 The main changes in this CL are: 1. The webidl is modified to allow passed back undefined. I'm told real webidl should support `(USVString or undefined)` here, but our webidl compiler does not support that. So we use `any` instead. 2. We must examine if the WTF::String is null or not before populating the returned array. If its null, then we convert to undefined instead. It turned out, however, that StringUTF8Adaptor was also converting empty strings to null strings. It was necessary to fix this in order to return undefined and empty string in the correct places in the returned values. Bug: 1292699 Change-Id: I27a0be2567bb9ce4592ca15a5216fd5a58bdbf17
This addresses the issues raised in: whatwg/urlpattern#162 The main changes in this CL are: 1. The webidl is modified to allow passed back undefined. I'm told real webidl should support `(USVString or undefined)` here, but our webidl compiler does not support that. So we use `any` instead. 2. We must examine if the WTF::String is null or not before populating the returned array. If its null, then we convert to undefined instead. It turned out, however, that StringUTF8Adaptor was also converting empty strings to null strings. It was necessary to fix this in order to return undefined and empty string in the correct places in the returned values. Bug: 1292699 Change-Id: I27a0be2567bb9ce4592ca15a5216fd5a58bdbf17
This addresses the issues raised in: whatwg/urlpattern#162 The main changes in this CL are: 1. The webidl is modified to allow passed back undefined. I'm told real webidl should support `(USVString or undefined)` here, but our webidl compiler does not support that. So we use `any` instead. 2. We must examine if the WTF::String is null or not before populating the returned array. If its null, then we convert to undefined instead. It turned out, however, that StringUTF8Adaptor was also converting empty strings to null strings. It was necessary to fix this in order to return undefined and empty string in the correct places in the returned values. Bug: 1292699 Change-Id: I27a0be2567bb9ce4592ca15a5216fd5a58bdbf17
This addresses the issues raised in: whatwg/urlpattern#162 The main changes in this CL are: 1. The webidl is modified to allow passed back undefined. I'm told real webidl should support `(USVString or undefined)` here, but our webidl compiler does not support that. So we use `any` instead. 2. We must examine if the WTF::String is null or not before populating the returned array. If its null, then we convert to undefined instead. It turned out, however, that StringUTF8Adaptor was also converting empty strings to null strings. It was necessary to fix this in order to return undefined and empty string in the correct places in the returned values. Bug: 1292699 Change-Id: I27a0be2567bb9ce4592ca15a5216fd5a58bdbf17
The spec and polyfill have been fixed. The implementation fix and WPT tests are still in review but should land shortly. |
This addresses the issues raised in: whatwg/urlpattern#162 The main changes in this CL are: 1. The webidl is modified to allow passed back undefined. I'm told real webidl should support `(USVString or undefined)` here, but our webidl compiler does not support that. So we use `any` instead. 2. We must examine if the WTF::String is null or not before populating the returned array. If its null, then we convert to undefined instead. Bug: 1292699 Change-Id: I27a0be2567bb9ce4592ca15a5216fd5a58bdbf17
This addresses the issues raised in: whatwg/urlpattern#162 The main changes in this CL are: 1. The webidl is modified to allow passed back undefined. I'm told real webidl should support `(USVString or undefined)` here, but our webidl compiler does not support that. So we use `any` instead. 2. We must examine if the WTF::String is null or not before populating the returned array. If its null, then we convert to undefined instead. Bug: 1292699 Change-Id: I27a0be2567bb9ce4592ca15a5216fd5a58bdbf17 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3428631 Reviewed-by: Jeremy Roman <[email protected]> Commit-Queue: Ben Kelly <[email protected]> Cr-Commit-Position: refs/heads/main@{#968611}
This addresses the issues raised in: whatwg/urlpattern#162 The main changes in this CL are: 1. The webidl is modified to allow passed back undefined. I'm told real webidl should support `(USVString or undefined)` here, but our webidl compiler does not support that. So we use `any` instead. 2. We must examine if the WTF::String is null or not before populating the returned array. If its null, then we convert to undefined instead. Bug: 1292699 Change-Id: I27a0be2567bb9ce4592ca15a5216fd5a58bdbf17 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3428631 Reviewed-by: Jeremy Roman <[email protected]> Commit-Queue: Ben Kelly <[email protected]> Cr-Commit-Position: refs/heads/main@{#968611}
This addresses the issues raised in: whatwg/urlpattern#162 The main changes in this CL are: 1. The webidl is modified to allow passed back undefined. I'm told real webidl should support `(USVString or undefined)` here, but our webidl compiler does not support that. So we use `any` instead. 2. We must examine if the WTF::String is null or not before populating the returned array. If its null, then we convert to undefined instead. Bug: 1292699 Change-Id: I27a0be2567bb9ce4592ca15a5216fd5a58bdbf17 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3428631 Reviewed-by: Jeremy Roman <[email protected]> Commit-Queue: Ben Kelly <[email protected]> Cr-Commit-Position: refs/heads/main@{#968611}
This addresses the issues raised in: whatwg/urlpattern#162 The main changes in this CL are: 1. The webidl is modified to allow passed back undefined. I'm told real webidl should support `(USVString or undefined)` here, but our webidl compiler does not support that. So we use `any` instead. 2. We must examine if the WTF::String is null or not before populating the returned array. If its null, then we convert to undefined instead. Bug: 1292699 Change-Id: I27a0be2567bb9ce4592ca15a5216fd5a58bdbf17 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3428631 Reviewed-by: Jeremy Roman <[email protected]> Commit-Queue: Ben Kelly <[email protected]> Cr-Commit-Position: refs/heads/main@{#968611}
…s to undefined instead of ''., a=testonly Automatic update from web-platform-tests URLPattern: Set unmatched optional groups to undefined instead of ''. This addresses the issues raised in: whatwg/urlpattern#162 The main changes in this CL are: 1. The webidl is modified to allow passed back undefined. I'm told real webidl should support `(USVString or undefined)` here, but our webidl compiler does not support that. So we use `any` instead. 2. We must examine if the WTF::String is null or not before populating the returned array. If its null, then we convert to undefined instead. Bug: 1292699 Change-Id: I27a0be2567bb9ce4592ca15a5216fd5a58bdbf17 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3428631 Reviewed-by: Jeremy Roman <[email protected]> Commit-Queue: Ben Kelly <[email protected]> Cr-Commit-Position: refs/heads/main@{#968611} -- wpt-commits: 111b696bdbb572a89065ce2d3cd524f7d6798301 wpt-pr: 32650
This addresses the issues raised in: whatwg/urlpattern#162 The main changes in this CL are: 1. The webidl is modified to allow passed back undefined. I'm told real webidl should support `(USVString or undefined)` here, but our webidl compiler does not support that. So we use `any` instead. 2. We must examine if the WTF::String is null or not before populating the returned array. If its null, then we convert to undefined instead. Bug: 1292699 Change-Id: I27a0be2567bb9ce4592ca15a5216fd5a58bdbf17 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3428631 Reviewed-by: Jeremy Roman <[email protected]> Commit-Queue: Ben Kelly <[email protected]> Cr-Commit-Position: refs/heads/main@{#968611}
…s to undefined instead of ''., a=testonly Automatic update from web-platform-tests URLPattern: Set unmatched optional groups to undefined instead of ''. This addresses the issues raised in: whatwg/urlpattern#162 The main changes in this CL are: 1. The webidl is modified to allow passed back undefined. I'm told real webidl should support `(USVString or undefined)` here, but our webidl compiler does not support that. So we use `any` instead. 2. We must examine if the WTF::String is null or not before populating the returned array. If its null, then we convert to undefined instead. Bug: 1292699 Change-Id: I27a0be2567bb9ce4592ca15a5216fd5a58bdbf17 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3428631 Reviewed-by: Jeremy Roman <[email protected]> Commit-Queue: Ben Kelly <[email protected]> Cr-Commit-Position: refs/heads/main@{#968611} -- wpt-commits: 111b696bdbb572a89065ce2d3cd524f7d6798301 wpt-pr: 32650
…s to undefined instead of ''., a=testonly Automatic update from web-platform-tests URLPattern: Set unmatched optional groups to undefined instead of ''. This addresses the issues raised in: whatwg/urlpattern#162 The main changes in this CL are: 1. The webidl is modified to allow passed back undefined. I'm told real webidl should support `(USVString or undefined)` here, but our webidl compiler does not support that. So we use `any` instead. 2. We must examine if the WTF::String is null or not before populating the returned array. If its null, then we convert to undefined instead. Bug: 1292699 Change-Id: I27a0be2567bb9ce4592ca15a5216fd5a58bdbf17 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3428631 Reviewed-by: Jeremy Roman <[email protected]> Commit-Queue: Ben Kelly <[email protected]> Cr-Commit-Position: refs/heads/main@{#968611} -- wpt-commits: 111b696bdbb572a89065ce2d3cd524f7d6798301 wpt-pr: 32650
…s to undefined instead of ''., a=testonly Automatic update from web-platform-tests URLPattern: Set unmatched optional groups to undefined instead of ''. This addresses the issues raised in: whatwg/urlpattern#162 The main changes in this CL are: 1. The webidl is modified to allow passed back undefined. I'm told real webidl should support `(USVString or undefined)` here, but our webidl compiler does not support that. So we use `any` instead. 2. We must examine if the WTF::String is null or not before populating the returned array. If its null, then we convert to undefined instead. Bug: 1292699 Change-Id: I27a0be2567bb9ce4592ca15a5216fd5a58bdbf17 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3428631 Reviewed-by: Jeremy Roman <[email protected]> Commit-Queue: Ben Kelly <[email protected]> Cr-Commit-Position: refs/heads/main@{#968611} -- wpt-commits: 111b696bdbb572a89065ce2d3cd524f7d6798301 wpt-pr: 32650
This addresses the issues raised in: whatwg/urlpattern#162 The main changes in this CL are: 1. The webidl is modified to allow passed back undefined. I'm told real webidl should support `(USVString or undefined)` here, but our webidl compiler does not support that. So we use `any` instead. 2. We must examine if the WTF::String is null or not before populating the returned array. If its null, then we convert to undefined instead. Bug: 1292699 Change-Id: I27a0be2567bb9ce4592ca15a5216fd5a58bdbf17 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3428631 Reviewed-by: Jeremy Roman <[email protected]> Commit-Queue: Ben Kelly <[email protected]> Cr-Commit-Position: refs/heads/main@{#968611} NOKEYCHECK=True GitOrigin-RevId: 27016ffa44b1b63cfef634f009ad881f90ee6e6c
test('/products/')
prints:So far so good: both agree the result is empty string...
But now...
test('/products')
prints:Is this expected behavior? Path-to-regexp's behavior here is preferable IMO... if the path does not end with a slash, one cannot rightly say that
remaining_path
had an empty string match, unless you assume that a url both without and with a trailing slash are exactly synonymous, which is not necessarily the case.(The same suboptimal results occur for
URLPattern
when using the more concise pattern/products/*?
)The text was updated successfully, but these errors were encountered: