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: url match logic of http server #199

Merged
merged 4 commits into from Feb 18, 2019
Merged

Conversation

keroxp
Copy link
Contributor

@keroxp keroxp commented Feb 17, 2019

  • Use only pathname for matching instead of full url
  • Fixed url match logic for regular expression

Currently, both "/foo" and "/bar/foo" are matched to /\/foo/ and the later is used because it is longer than the former. This is correct but strange behavior for url routing. I changed logic of evaluation for priority of matches:

  • Matches with the earliest index (RegexMatchArray.index) is prior to others.
  • The longest match is picked from them.

With this logic,

  • "/foo" is prior to "/bar/foo" because the former matched to /\/foo/ at index 0.
  • "/foo/bar" is prior to "/foo" because the former has longer match than the later.

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

LGTM

@ry ry merged commit da188a7 into denoland:master Feb 18, 2019
ry pushed a commit to ry/deno that referenced this pull request Oct 9, 2019
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.

None yet

2 participants