mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-22 23:02:40 +01:00
fix(#124): resolve all *.localhost to localhost
This commit is contained in:
parent
6632ae1dcb
commit
96d50ebd93
@ -1,6 +1,7 @@
|
||||
const os = require('os');
|
||||
const fs = require('fs');
|
||||
const qs = require('qs');
|
||||
const parseUrl = require('url').parse;
|
||||
const https = require('https');
|
||||
const axios = require('axios');
|
||||
const path = require('path');
|
||||
@ -74,6 +75,14 @@ const getEnvVars = (environment = {}) => {
|
||||
|
||||
const protocolRegex = /([a-zA-Z]{2,20}:\/\/)(.*)/;
|
||||
|
||||
const getTld = (hostname) => {
|
||||
if (!hostname) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return hostname.substring(hostname.lastIndexOf('.') + 1);
|
||||
};
|
||||
|
||||
const configureRequest = async (
|
||||
collectionUid,
|
||||
request,
|
||||
@ -174,6 +183,15 @@ const configureRequest = async (
|
||||
});
|
||||
}
|
||||
|
||||
// resolve all *.localhost to localhost
|
||||
// RFC: 6761 section 6.3 (https://tools.ietf.org/html/rfc6761#section-6.3)
|
||||
// @see https://github.com/usebruno/bruno/issues/124
|
||||
let parsedUrl = parseUrl(request.url);
|
||||
if (getTld(parsedUrl.hostname) === 'localhost') {
|
||||
request.headers['Host'] = parsedUrl.hostname;
|
||||
request.url = request.url.replace(parsedUrl.hostname, 'localhost');
|
||||
}
|
||||
|
||||
const axiosInstance = makeAxiosInstance();
|
||||
|
||||
if (request.awsv4config) {
|
||||
|
Loading…
Reference in New Issue
Block a user