2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00

Returned error treated when requesting uncommon URL (#3544)

* Fixing error returned when requesting illegal URL

* Adding unit tests http.js

* Fixing error message axios invalid request from browser

* Adding unit tests requests.spec.js

* Adding at utils.js a new method: getProtocol

Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
João Gabriel Quaresma
2022-03-07 14:53:57 -03:00
committed by GitHub
parent 412d3bd607
commit 195c8e5ff5
5 changed files with 170 additions and 2 deletions
+9 -1
View File
@@ -122,7 +122,15 @@ module.exports = function httpAdapter(config) {
// Parse url
var fullPath = buildFullPath(config.baseURL, config.url);
var parsed = url.parse(fullPath);
var protocol = parsed.protocol || 'http:';
var protocol = utils.getProtocol(parsed.protocol);
if (parsed.path === null) {
return reject(createError('Malformed URL ' + fullPath, config));
}
if (!utils.supportedProtocols.includes(protocol)) {
return reject(createError('Unsupported protocol ' + protocol, config));
}
if (!auth && parsed.auth) {
var urlAuth = parsed.auth.split(':');