Skip to content

Commit d112def

Browse files
committed
Meta tweaks
1 parent 9a44d07 commit d112def

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
const DATA_URL_DEFAULT_MIME_TYPE = 'text/plain';
33
const DATA_URL_DEFAULT_CHARSET = 'us-ascii';
44

5-
const testParameter = (name, filters) => {
6-
return filters.some(filter => filter instanceof RegExp ? filter.test(name) : filter === name);
7-
};
5+
const testParameter = (name, filters) => filters.some(filter => filter instanceof RegExp ? filter.test(name) : filter === name);
86

97
const normalizeDataURL = (urlString, {stripHash}) => {
108
const match = /^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(urlString);
@@ -43,7 +41,7 @@ const normalizeDataURL = (urlString, {stripHash}) => {
4341
.filter(Boolean);
4442

4543
const normalizedMediaType = [
46-
...attributes
44+
...attributes,
4745
];
4846

4947
if (isBase64) {
@@ -72,7 +70,7 @@ export default function normalizeUrl(urlString, options) {
7270
removeSingleSlash: true,
7371
removeDirectoryIndex: false,
7472
sortQueryParameters: true,
75-
...options
73+
...options,
7674
};
7775

7876
urlString = urlString.trim();

index.test-d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ normalizeUrl('sindresorhus.com/about.html#contact', {stripHash: true});
1313
normalizeUrl('https://sindresorhus.com', {stripProtocol: true});
1414
normalizeUrl('http://www.sindresorhus.com', {stripWWW: false});
1515
normalizeUrl('www.sindresorhus.com?foo=bar&ref=test_ref', {
16-
removeQueryParameters: ['ref', /test/]
16+
removeQueryParameters: ['ref', /test/],
1717
});
1818
normalizeUrl('www.sindresorhus.com?foo=bar', {
19-
removeQueryParameters: true
19+
removeQueryParameters: true,
2020
});
2121
normalizeUrl('www.sindresorhus.com?foo=bar&utm_medium=test&ref=test_ref', {
22-
removeQueryParameters: false
22+
removeQueryParameters: false,
2323
});
2424
normalizeUrl('http://sindresorhus.com/', {removeTrailingSlash: false});
2525
normalizeUrl('http://sindresorhus.com/', {removeSingleSlash: false});
2626
normalizeUrl('www.sindresorhus.com/foo/default.php', {
27-
removeDirectoryIndex: [/^default\.[a-z]+$/, 'foo']
27+
removeDirectoryIndex: [/^default\.[a-z]+$/, 'foo'],
2828
});
2929
normalizeUrl('www.sindresorhus.com?b=two&a=one&c=three', {
30-
sortQueryParameters: false
30+
sortQueryParameters: false,
3131
});
3232
normalizeUrl('www.sindresorhus.com/about#:~:text=hello', {
33-
stripTextFragment: false
33+
stripTextFragment: false,
3434
});

license

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
3+
Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"ava": "^3.15.0",
4242
"nyc": "^15.1.0",
4343
"tsd": "^0.17.0",
44-
"xo": "^0.40.3"
44+
"xo": "^0.41.0"
4545
},
4646
"nyc": {
4747
"reporter": [

test.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ test('stripWWW option', t => {
111111
test('removeQueryParameters option', t => {
112112
const options = {
113113
stripWWW: false,
114-
removeQueryParameters: [/^utm_\w+/i, 'ref']
114+
removeQueryParameters: [/^utm_\w+/i, 'ref'],
115115
};
116116
t.is(normalizeUrl('www.sindresorhus.com?foo=bar&utm_medium=test'), 'http://sindresorhus.com/?foo=bar');
117117
t.is(normalizeUrl('http://www.sindresorhus.com', options), 'http://www.sindresorhus.com');
@@ -122,7 +122,7 @@ test('removeQueryParameters option', t => {
122122
test('removeQueryParameters boolean `true` option', t => {
123123
const options = {
124124
stripWWW: false,
125-
removeQueryParameters: true
125+
removeQueryParameters: true,
126126
};
127127

128128
t.is(normalizeUrl('http://www.sindresorhus.com', options), 'http://www.sindresorhus.com');
@@ -133,7 +133,7 @@ test('removeQueryParameters boolean `true` option', t => {
133133
test('removeQueryParameters boolean `false` option', t => {
134134
const options = {
135135
stripWWW: false,
136-
removeQueryParameters: false
136+
removeQueryParameters: false,
137137
};
138138

139139
t.is(normalizeUrl('http://www.sindresorhus.com', options), 'http://www.sindresorhus.com');
@@ -153,7 +153,7 @@ test('forceHttp option with forceHttps', t => {
153153
t.throws(() => {
154154
normalizeUrl('https://www.sindresorhus.com', {forceHttp: true, forceHttps: true});
155155
}, {
156-
message: 'The `forceHttp` and `forceHttps` options cannot be used together'
156+
message: 'The `forceHttp` and `forceHttps` options cannot be used together',
157157
});
158158
});
159159

@@ -231,7 +231,7 @@ test('removeDirectoryIndex option', t => {
231231
test('removeTrailingSlash and removeDirectoryIndex options)', t => {
232232
const options1 = {
233233
removeTrailingSlash: true,
234-
removeDirectoryIndex: true
234+
removeDirectoryIndex: true,
235235
};
236236
t.is(normalizeUrl('http://sindresorhus.com/path/', options1), 'http://sindresorhus.com/path');
237237
t.is(normalizeUrl('http://sindresorhus.com/path/index.html', options1), 'http://sindresorhus.com/path');
@@ -240,7 +240,7 @@ test('removeTrailingSlash and removeDirectoryIndex options)', t => {
240240

241241
const options2 = {
242242
removeTrailingSlash: false,
243-
removeDirectoryIndex: true
243+
removeDirectoryIndex: true,
244244
};
245245
t.is(normalizeUrl('http://sindresorhus.com/path/', options2), 'http://sindresorhus.com/path/');
246246
t.is(normalizeUrl('http://sindresorhus.com/path/index.html', options2), 'http://sindresorhus.com/path/');
@@ -249,15 +249,15 @@ test('removeTrailingSlash and removeDirectoryIndex options)', t => {
249249

250250
test('sortQueryParameters option', t => {
251251
const options1 = {
252-
sortQueryParameters: true
252+
sortQueryParameters: true,
253253
};
254254
t.is(normalizeUrl('http://sindresorhus.com/?a=Z&b=Y&c=X&d=W', options1), 'http://sindresorhus.com/?a=Z&b=Y&c=X&d=W');
255255
t.is(normalizeUrl('http://sindresorhus.com/?b=Y&c=X&a=Z&d=W', options1), 'http://sindresorhus.com/?a=Z&b=Y&c=X&d=W');
256256
t.is(normalizeUrl('http://sindresorhus.com/?a=Z&d=W&b=Y&c=X', options1), 'http://sindresorhus.com/?a=Z&b=Y&c=X&d=W');
257257
t.is(normalizeUrl('http://sindresorhus.com/', options1), 'http://sindresorhus.com');
258258

259259
const options2 = {
260-
sortQueryParameters: false
260+
sortQueryParameters: false,
261261
};
262262
t.is(normalizeUrl('http://sindresorhus.com/?a=Z&b=Y&c=X&d=W', options2), 'http://sindresorhus.com/?a=Z&b=Y&c=X&d=W');
263263
t.is(normalizeUrl('http://sindresorhus.com/?b=Y&c=X&a=Z&d=W', options2), 'http://sindresorhus.com/?b=Y&c=X&a=Z&d=W');
@@ -269,19 +269,19 @@ test('invalid urls', t => {
269269
t.throws(() => {
270270
normalizeUrl('http://');
271271
}, {
272-
message: 'Invalid URL'
272+
message: 'Invalid URL',
273273
});
274274

275275
t.throws(() => {
276276
normalizeUrl('/');
277277
}, {
278-
message: 'Invalid URL'
278+
message: 'Invalid URL',
279279
});
280280

281281
t.throws(() => {
282282
normalizeUrl('/relative/path/');
283283
}, {
284-
message: 'Invalid URL'
284+
message: 'Invalid URL',
285285
});
286286
});
287287

@@ -309,8 +309,10 @@ test('remove duplicate pathname slashes', t => {
309309

310310
test('data URL', t => {
311311
// Invalid URL.
312-
t.throws(() => normalizeUrl('data:'), {
313-
message: 'Invalid URL: data:'
312+
t.throws(() => {
313+
normalizeUrl('data:');
314+
}, {
315+
message: 'Invalid URL: data:',
314316
});
315317

316318
// Strip default MIME type
@@ -357,7 +359,7 @@ test('data URL', t => {
357359
removeQueryParameters: [/^utm_\w+/i, 'ref'],
358360
sortQueryParameters: true,
359361
removeTrailingSlash: true,
360-
removeDirectoryIndex: true
362+
removeDirectoryIndex: true,
361363
};
362364
t.is(normalizeUrl('data:,sindresorhus.com/', options), 'data:,sindresorhus.com/');
363365
t.is(normalizeUrl('data:,sindresorhus.com/index.html', options), 'data:,sindresorhus.com/index.html');
@@ -375,7 +377,7 @@ test('view-source URL', t => {
375377
t.throws(() => {
376378
normalizeUrl('view-source:https://www.sindresorhus.com');
377379
}, {
378-
message: '`view-source:` is not supported as it is a non-standard protocol'
380+
message: '`view-source:` is not supported as it is a non-standard protocol',
379381
});
380382
});
381383

0 commit comments

Comments
 (0)