Skip to content
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

fix: don't mistake paths for protocols #6212

Merged
merged 14 commits into from
Nov 28, 2023
Merged

fix: don't mistake paths for protocols #6212

merged 14 commits into from
Nov 28, 2023

Conversation

Skn0tt
Copy link
Contributor

@Skn0tt Skn0tt commented Nov 27, 2023

Found another small bug in our routing logic for v2 functions. When requesting a path like //foo, our routing logic was mistaking the // to be a protocol separator, and inferred foo to be the hostname instead of the path.

This PR fixes that!

@Skn0tt Skn0tt requested a review from eduardoboucas November 27, 2023 15:23
@Skn0tt Skn0tt self-assigned this Nov 27, 2023
@Skn0tt Skn0tt requested a review from a team as a code owner November 27, 2023 15:23
// We're constructing a URL object just so that we can extract the path from
// the incoming URL. It doesn't really matter that we don't have the actual
// local URL with the correct port.
const urlPath = new URL(url, 'http://localhost').pathname
Copy link
Contributor Author

@Skn0tt Skn0tt Nov 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here's an example for why this broke: Screenshot 2023-11-27 at 16 23 40

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is nothing ensuring that urlPath is indeed a URL path and not a full URL, right? I have a feeling that this is precisely why we had this logic here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've played around with it a bit more, and it seems like we had this in place to remove query parameters from the path. 146cb80 implements a fix that still does that

Copy link

github-actions bot commented Nov 27, 2023

📊 Benchmark results

Comparing with af800af

  • Dependency count: 1,396 (no change)
  • Package size: 404 MB (no change)
  • Number of ts-expect-error directives: 0 (no change)

@eduardoboucas eduardoboucas changed the title fix: dont mistake paths for protocols fix: don't mistake paths for protocols Nov 27, 2023
src/lib/functions/registry.ts Outdated Show resolved Hide resolved
@@ -297,8 +297,8 @@ export class FunctionsRegistry {
async getFunctionForURLPath(url, method) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter should probably be named to urlPath, as it will now break if it's a fully qualified URL? Alternatively, we can keep it as url and check whether if it's a full URL or a URL path, adjusting accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in f205690

@Skn0tt Skn0tt requested a review from eduardoboucas November 27, 2023 16:55
@Skn0tt Skn0tt enabled auto-merge (squash) November 27, 2023 17:03
@Skn0tt Skn0tt disabled auto-merge November 28, 2023 07:13
@Skn0tt Skn0tt merged commit 3c31fc9 into main Nov 28, 2023
33 checks passed
@Skn0tt Skn0tt deleted the v2-func-edge-case branch November 28, 2023 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants