Replace new URL usage with URL.parse/URL.canParse where possible
Categories
(Firefox :: General, enhancement, P1)
Tracking
()
Tracking | Status | |
---|---|---|
firefox137 | --- | fixed |
People
(Reporter: kernp25, Assigned: kernp25)
References
Details
Attachments
(1 file)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0
Actual results:
Instead of using try { new URL(...) } catch (ex) {}
just use URL.parse/URL.canParse.
Updated•2 months ago
|
Updated•1 months ago
|
Updated•1 month ago
|
Comment 4•12 days ago
|
||
Backed out for causing failures at test_JsonSchemaValidator.js.
Backout link: https://hg.mozilla.org/integration/autoland/rev/67af6fcfd17c320191d5424212161d520a6584f2
Failure log: https://treeherder.mozilla.org/logviewer?job_id=493181619&repo=autoland&lineNumber=4740
Do you know why this test is failing? The test must be changed? It says parsedValue - null === "".
Comment 6•12 days ago
|
||
(In reply to kernp25 from comment #5)
Do you know why this test is failing? The test must be changed? It says parsedValue - null === "".
At the start of the function, there's this line: let parsedParam = param;
. In this case, I think it is setting parsedParam
to the empty string. Your patch changes the code from try { parsedParam = new URI(param) } catch ...
to parsedParam = URL.parse(param);
.
Due to that change, if the param cannot be parsed, we're now returning null
rather than ""
.
Looking at this documentation it might be acceptable to change the return type there - the result isn't valid, so we shouldn't be looking at the parsedParam
anyway.
However, I don't know the code well enough here to know if that's acceptable, so forwarding the NI to :dmose who hopefully will have an eye..
Should I change the parsedParam = URL.parse(param);
line to parsedParam = URL.parse(param) ?? "";
?
Or better, I should reset the parsedParam variable to parsedParam = param;
here?
Comment 9•12 days ago
|
||
The options here are why I'm asking :dmose. I don't know enough to know if it is safe to change what we return (and hence we can update the test) or change the code to match the test. Whilst we could change the code rather than the test, that is then extra code that we'll need to explain.
Assignee | ||
Comment 10•9 days ago
|
||
Can you now push again? The other case will be handled in bug 1946723.
Comment 11•6 days ago
|
||
(In reply to kernp25 from comment #10)
Can you now push again? The other case will be handled in bug 1946723.
Thank you, that's a good way of handling this, I've just trigged landing again.
Comment 12•6 days ago
|
||
Comment 13•5 days ago
|
||
bugherder |
Description
•