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

check-endpoints.py: Updating regex to treat search items as distinct path. #17

Merged
merged 1 commit into from
May 25, 2023

Conversation

thegrapesoda
Copy link
Contributor

@thegrapesoda thegrapesoda commented May 25, 2023

Fixes #10

Issue was a result of how the regex search is being performed. It searches for each item without the leading '/', and it doesn't search in the context of the item being used as an exact path.

So "/oauth" becomes "oauth" - which exists as a string on its own elsewhere in clients.py. "/api/token" becomes "api/token", which has a child ("api/token/test") in clients.py, which is being counted as a match because the string "api/token" can be found in the string "api/token/test").

I fixed this (kinda hacky) by adding a " (double quote) to the end of the string the regex searches for, so the examples above will now search for oauth**"** and api/token/test**"** - which do not exist on their own as distinct path = " items.

A better fix would be to search for the string in leading and trailing double-quotes, or even force compliance that all paths have to take the format path = "" - however, some paths in clients.py have been entered with a leading "/" (path = "/api/rel/following" is an example), and 1) adding logic to account for this would add more complexity, and 2) I'd rather not edit clients.py to force that compliance because I'm concerned about breaking something.

@thegrapesoda thegrapesoda changed the title Updating regex to treat search items as distinct path. #10 Updating regex to treat search items as distinct path. May 25, 2023
@benediktwerner
Copy link
Member

Thanks!

One option would have been to make the leading slash optional i.e. add "/? to the front of the regex. But tbh it's weird that they don't have the leading slash, I'll add it everywhere.

@benediktwerner benediktwerner changed the title Updating regex to treat search items as distinct path. check-endpoints.py: Updating regex to treat search items as distinct path. May 25, 2023
@benediktwerner benediktwerner merged commit 2493de8 into lichess-org:master May 25, 2023
@thegrapesoda thegrapesoda deleted the chkEndpts-1 branch May 25, 2023 18:53
@thegrapesoda
Copy link
Contributor Author

Oh awesome - thanks!

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.

check-endpoints.py not finding all missing endpoints
2 participants