This commit is contained in:
syuilo 2016-09-13 06:02:27 +09:00
parent 65de5ae1fb
commit 33132b2ba2
2 changed files with 7 additions and 2 deletions

View File

@ -9,7 +9,7 @@ Installation
Usage Usage
----- -----
`(url: string, opts: Options) => Promise<string>` `(url: string, options: Options) => Promise<string>`
### Options ### Options
| Property | Type | Description | Default | | Property | Type | Description | Default |

View File

@ -11,9 +11,14 @@ const plugins: IPlugin[] = [
require('./plugins/wikipedia') require('./plugins/wikipedia')
]; ];
export default async (url: string, opts: Options): Promise<string> => { export default async (url: string, options?: Options): Promise<string> => {
const _url = URL.parse(url, true); const _url = URL.parse(url, true);
const opts: any = options || {};
if (!opts.hasOwnProperty('proxy')) {
opts.proxy = null;
}
const plugin = plugins.filter(plugin => plugin.test(_url))[0]; const plugin = plugins.filter(plugin => plugin.test(_url))[0];
if (plugin) { if (plugin) {