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

Returned error treated when requesting uncommon URL #3544

Conversation

joaoGabriel55
Copy link
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

buyan302 commented Jan 14, 2021

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

@joaoGabriel55
Copy link
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
Contributor Author

Currently, the URL validating are these:

Malformed URL:

image

Unsupported protocol:

image

@joaoGabriel55
Copy link
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.

lib/adapters/xhr.js Outdated Show resolved Hide resolved
lib/utils.js Show resolved Hide resolved
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.

None yet

4 participants