Skip to content

Commit

Permalink
Hard-deprecate some deprecated options
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Nov 6, 2018
1 parent b853763 commit f066795
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 0 additions & 6 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit f066795

Please sign in to comment.