Skip to content

Ensure accurate root_path removal in get_route_path function#2600

Merged
Kludex merged 5 commits intoKludex:masterfrom
gabriel-f-santos:fix/regex-get_route_path
Sep 1, 2024
Merged

Ensure accurate root_path removal in get_route_path function#2600
Kludex merged 5 commits intoKludex:masterfrom
gabriel-f-santos:fix/regex-get_route_path

Conversation

@gabriel-f-santos
Copy link
Copy Markdown
Contributor

Issue: #2599
Discussion: #2495

Summary

Change regex used to remove root_path to consider only the root path without match simillar endpoint that contains the root_path as substring.
ex:

root_path = "product"
scope["path"] = "products/all"

before:

re.sub(r"^" + root_path, "", scope["path"]) -> 's/all'

after:

re.sub(r"^" + root_path + r"(?=/|$)", "", scope["path"]) -> '/products/all'

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

@Kludex
Copy link
Copy Markdown
Owner

Kludex commented Aug 21, 2024

Is there a way we can use removeprefix instead?

@Kludex Kludex changed the title fix: regex inside function get_route_path to remove root_path Ensure accurate root_path removal in get_route_path function Sep 1, 2024
@Kludex Kludex merged commit 1131b3c into Kludex:master Sep 1, 2024
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