2017-06-20 16:57:30 +00:00
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const request = require('../helpers/context').request;
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
describe('req.URL', () => {
|
|
|
|
describe('should not throw when', () => {
|
|
|
|
it('host is void', () => {
|
2018-04-10 02:36:52 +00:00
|
|
|
// Accessing the URL should not throw.
|
|
|
|
request().URL;
|
2017-06-20 16:57:30 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('header.host is invalid', () => {
|
|
|
|
const req = request();
|
|
|
|
req.header.host = 'invalid host';
|
2018-04-10 02:36:52 +00:00
|
|
|
// Accessing the URL should not throw.
|
|
|
|
req.URL;
|
2017-06-20 16:57:30 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return empty object when invalid', () => {
|
|
|
|
const req = request();
|
|
|
|
req.header.host = 'invalid host';
|
|
|
|
assert.deepStrictEqual(req.URL, Object.create(null));
|
|
|
|
});
|
|
|
|
});
|