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

Improve parse_url usage #254

Open
gRegorLove opened this issue Mar 6, 2024 · 0 comments
Open

Improve parse_url usage #254

gRegorLove opened this issue Mar 6, 2024 · 0 comments

Comments

@gRegorLove
Copy link
Member

In some edge cases, I’ve gotten a TypeError in parseUriToComponents(), when called by the function resolveUrl() (not the class method of the same name). This happens because parse_url can return false and it’s not checking for that before calling array_key_exists:

array_key_exists(): Argument #2 ($array) must be of type array, bool given

A real-world example is @pmoralesgarcia has domain-relative links like href="/blog/tag:2024/" which parse_url has trouble with, probably because of the colon. I haven’t researched the best solution, but something like the class method might be enough. It might be worth seeing what sabre-io/uri does. I’ve been using that in some other code and liking it so far.

(Originally published at: https://gregorlove.com/2024/03/improve-parse-url-usage/)

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

No branches or pull requests

1 participant