light-my-request
Advanced tools
Comparing version 4.4.3 to 4.4.4
@@ -15,2 +15,5 @@ 'use strict' | ||
module.exports = function parseURL (url, query) { | ||
if ((typeof url === 'string' || Object.prototype.toString.call(url) === '[object String]') && url.startsWith('//')) { | ||
url = BASE_URL + url | ||
} | ||
const result = typeof url === 'object' | ||
@@ -17,0 +20,0 @@ ? Object.assign(new URL(BASE_URL), url) |
{ | ||
"name": "light-my-request", | ||
"version": "4.4.3", | ||
"version": "4.4.4", | ||
"description": "Fake HTTP injection library", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -20,3 +20,2 @@ 'use strict' | ||
const formAutoContent = require('form-auto-content') | ||
const httpMethods = [ | ||
@@ -1710,1 +1709,39 @@ 'delete', | ||
}) | ||
test('value of request url when using inject should not differ', (t) => { | ||
t.plan(1) | ||
const server = http.createServer() | ||
const dispatch = function (req, res) { | ||
res.end(req.url) | ||
} | ||
inject(dispatch, { method: 'GET', url: 'http://example.com:8080//hello', server: server }) | ||
.then(res => { t.equal(res.body, '//hello') }) | ||
.catch(err => t.error(err)) | ||
}) | ||
test('Can parse paths with single leading slash', (t) => { | ||
t.plan(1) | ||
const parsedURL = parseURL('/test', undefined) | ||
t.equal(parsedURL.href, 'http://localhost/test') | ||
}) | ||
test('Can parse paths with two leading slashes', (t) => { | ||
t.plan(1) | ||
const parsedURL = parseURL('//test', undefined) | ||
t.equal(parsedURL.href, 'http://localhost//test') | ||
}) | ||
test('Can parse URLs with two leading slashes', (t) => { | ||
t.plan(1) | ||
const parsedURL = parseURL('https://example.com//test', undefined) | ||
t.equal(parsedURL.href, 'https://example.com//test') | ||
}) | ||
test('Can parse URLs with single leading slash', (t) => { | ||
t.plan(1) | ||
const parsedURL = parseURL('https://example.com/test', undefined) | ||
t.equal(parsedURL.href, 'https://example.com/test') | ||
}) |
82276
2271