-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require Node.js 12.20 and move to ESM
- Loading branch information
1 parent
70c5abd
commit 0a2693b
Showing
8 changed files
with
35 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,22 @@ | ||
import {Options as FilenamifyOptions} from 'filenamify'; | ||
import {Options} from 'filenamify'; | ||
|
||
declare namespace filenamifyUrl { | ||
type Options = FilenamifyOptions; | ||
} | ||
/** | ||
Convert a URL to a valid filename. | ||
declare const filenamifyUrl: { | ||
/** | ||
Convert a URL to a valid filename. | ||
@param url - A URL to convert to a valid filename. | ||
@returns A valid filename for `url`. | ||
@param url - A URL to convert to a valid filename. | ||
@returns A valid filename for `url`. | ||
@example | ||
``` | ||
import filenamifyUrl from 'filenamify-url'; | ||
@example | ||
``` | ||
import filenamifyUrl = require('filenamify-url'); | ||
filenamifyUrl('http://sindresorhus.com/foo?bar=baz'); | ||
//=> 'sindresorhus.com!foo!bar=baz' | ||
filenamifyUrl('http://sindresorhus.com/foo?bar=baz'); | ||
//=> 'sindresorhus.com!foo!bar=baz' | ||
filenamifyUrl('http://sindresorhus.com/foo', {replacement: '🐴'}); | ||
//=> 'sindresorhus.com🐴foo' | ||
``` | ||
*/ | ||
export default function filenamifyUrl(url: string, options?: Options): string; | ||
|
||
filenamifyUrl('http://sindresorhus.com/foo', {replacement: '🐴'}); | ||
//=> 'sindresorhus.com🐴foo' | ||
``` | ||
*/ | ||
(url: string, options?: filenamifyUrl.Options): string; | ||
|
||
// TODO: Remove this for the next major release, refactor the whole definition to: | ||
// declare function filenamifyUrl(url: string, options?: Options): string; | ||
// export = filenamifyUrl; | ||
default: typeof filenamifyUrl; | ||
}; | ||
|
||
export = filenamifyUrl; | ||
export {Options} from 'filenamify'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
'use strict'; | ||
const filenamify = require('filenamify'); | ||
const humanizeUrl = require('humanize-url'); | ||
import filenamify from 'filenamify'; | ||
import humanizeUrl from 'humanize-url'; | ||
|
||
const filenamifyUrl = (string, options) => { | ||
export default function filenamifyUrl(string, options) { | ||
if (typeof string !== 'string') { | ||
throw new TypeError('Expected a string'); | ||
} | ||
|
||
return filenamify(decodeURIComponent(humanizeUrl(string)), options); | ||
}; | ||
|
||
module.exports = filenamifyUrl; | ||
// TODO: Remove this for the next major release | ||
module.exports.default = filenamifyUrl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import {expectType} from 'tsd'; | ||
import filenamifyUrl = require('.'); | ||
import filenamifyUrl from './index.js'; | ||
|
||
expectType<string>(filenamifyUrl('http://sindresorhus.com/foo?bar=baz')); | ||
expectType<string>( | ||
filenamifyUrl('http://sindresorhus.com/foo', {replacement: '🐴'}) | ||
filenamifyUrl('http://sindresorhus.com/foo', {replacement: '🐴'}), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
MIT License | ||
|
||
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com) | ||
Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com) | ||
|
||
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: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,10 @@ | |
"email": "[email protected]", | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=8" | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd" | ||
|
@@ -31,12 +33,12 @@ | |
"url" | ||
], | ||
"dependencies": { | ||
"filenamify": "^4.3.0", | ||
"humanize-url": "^2.1.1" | ||
"filenamify": "^5.0.1", | ||
"humanize-url": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^2.4.0", | ||
"tsd": "^0.11.0", | ||
"xo": "^0.25.3" | ||
"ava": "^3.15.0", | ||
"tsd": "^0.17.0", | ||
"xo": "^0.44.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters