Skip to content

Commit

Permalink
Fix #60 - URL is not a constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Marios Antonoudiou committed May 31, 2018
1 parent 2a710f8 commit efbaeaf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
const {URL} = require('url');
const URLParser = typeof URL === 'undefined' ? require('url').URL : URL;

function testParameter(name, filters) {
return filters.some(filter => filter instanceof RegExp ? filter.test(name) : filter === name);
Expand Down Expand Up @@ -27,7 +27,7 @@ module.exports = (urlString, opts) => {
urlString = urlString.replace(/^(?!(?:\w+:)?\/\/)|^\/\//, 'http://');
}

const urlObj = new URL(urlString);
const urlObj = new URLParser(urlString);

if (opts.normalizeHttps && urlObj.protocol === 'https:') {
urlObj.protocol = 'http:';
Expand Down

0 comments on commit efbaeaf

Please sign in to comment.