php-mf2 icon indicating copy to clipboard operation
php-mf2 copied to clipboard

Improve parse_url usage

Open gRegorLove opened this issue 2 years ago • 0 comments

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/)

gRegorLove avatar Mar 06 '24 03:03 gRegorLove