Skip to content

Returned error treated when requesting uncommon URL#3544

Merged
jasonsaayman merged 6 commits intoaxios:masterfrom
joaoGabriel55:issue-error-returned-when-requesting-illegal-URL
Mar 7, 2022
Merged

Returned error treated when requesting uncommon URL#3544
jasonsaayman merged 6 commits intoaxios:masterfrom
joaoGabriel55:issue-error-returned-when-requesting-illegal-URL

Conversation

@joaoGabriel55
Copy link
Copy Markdown
Contributor

Fix the irrelevant error returned when requesting uncommon URL - Open Issue #3509

When axios request to an illegal URL like "tel:484-695-3408", the error message is irrelevant.

TypeError: Cannot read property 'replace' of null
    at dispatchHttpRequest (node_modules/axios/lib/adapters/http.js:109:74)
    at new Promise (<anonymous>)
    at httpAdapter (node_modules/axios/lib/adapters/http.js:46:10)
    at dispatchRequest (node_modules/axios/lib/core/dispatchRequest.js:52:10)

So, I fixed this, validating the "path" property from "parsed" object, cheking if it is null, throwing an error message: "Malformed URL". And I checked too, if the URL protocol is supported (HTTP or HTTPS) throwing a message: "Unsupported protocol ".

@joaoGabriel55 joaoGabriel55 changed the title Returned error treated when requesting illegal URL Returned error treated when requesting uncommon URL Jan 13, 2021
@buyan302
Copy link
Copy Markdown

buyan302 commented Jan 14, 2021

I suggest that keep the URL validating behavior the same in both node an browser.

@joaoGabriel55
Copy link
Copy Markdown
Contributor Author

joaoGabriel55 commented Jan 14, 2021

If I understand, this URL validating behavior (error messages) must be present too, in axios requests made by client (browser). Would be this?

@joaoGabriel55
Copy link
Copy Markdown
Contributor Author

Currently, the URL validating are these:

Malformed URL:

image

Unsupported protocol:

image

@joaoGabriel55
Copy link
Copy Markdown
Contributor Author

Hello @buyan302, I simplely, used the same logic of my new error messages from node on xhr.js. And I added one more supported protocol: file:.

Waiting for your feedback.

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.

4 participants