From f0667958dd4c19ccee3a4ee73e3d858735eaa0bf Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Tue, 6 Nov 2018 13:02:01 +0700 Subject: [PATCH] Hard-deprecate some deprecated options --- index.js | 8 ++++---- test.js | 6 ------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 856528b..97beb30 100644 --- a/index.js +++ b/index.js @@ -21,17 +21,17 @@ module.exports = (urlString, options) => { sortQueryParameters: true }, options); - // Backwards compatibility + // TODO: Remove this at some point in the future if (Reflect.has(options, 'normalizeHttps')) { - options.forceHttp = options.normalizeHttps; + throw new Error('options.normalizeHttps is renamed to options.forceHttp'); } if (Reflect.has(options, 'normalizeHttp')) { - options.forceHttps = options.normalizeHttp; + throw new Error('options.normalizeHttp is renamed to options.forceHttps'); } if (Reflect.has(options, 'stripFragment')) { - options.stripHash = options.stripFragment; + throw new Error('options.stripFragment is renamed to options.stripHash'); } urlString = urlString.trim(); diff --git a/test.js b/test.js index bddf1b3..9333d35 100644 --- a/test.js +++ b/test.js @@ -48,12 +48,6 @@ test('main', t => { t.is(normalizeUrl('sindre://user:password@www.sorhus.com'), 'sindre://sorhus.com'); }); -test('backwards compatibility', t => { - t.is(normalizeUrl('http://sindresorhus.com/foo#bar', {stripFragment: false}), 'http://sindresorhus.com/foo#bar'); - t.is(normalizeUrl('https://sindresorhus.com', {normalizeHttps: true}), 'http://sindresorhus.com'); - t.is(normalizeUrl('http://sindresorhus.com', {normalizeHttp: true}), 'https://sindresorhus.com'); -}); - test('stripAuthentication option', t => { const options = {stripAuthentication: false}; t.is(normalizeUrl('http://user:password@www.sindresorhus.com', options), 'http://user:password@sindresorhus.com');