Skip to content

fix: Prevent potential panic when extracting x_token from URL#179

Open
zkpepe wants to merge 1 commit intoEllipsis-Labs:masterfrom
zkpepe:patch-1
Open

fix: Prevent potential panic when extracting x_token from URL#179
zkpepe wants to merge 1 commit intoEllipsis-Labs:masterfrom
zkpepe:patch-1

Conversation

@zkpepe
Copy link

@zkpepe zkpepe commented Mar 10, 2025

Noticed a potential issue in the x_token extraction logic. If the provided URL doesn’t contain a /, the .pop().unwrap() call could cause a panic.

To prevent this, I replaced url.split('/') with url.rsplitn(2, '/') and added a check to ensure we have enough parts before attempting to extract x_token.

Now, if the URL format is invalid, the code returns an error instead of panicking.

Signed-off-by: zkpepe <shim.growers_6u@icloud.com>
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.

1 participant