mirror of
https://github.com/misskey-dev/summaly.git
synced 2025-08-02 22:36:34 +09:00
Fix bug and incorrect type definitions
This commit is contained in:
@ -14,7 +14,7 @@ client.set('timeout', 10000);
|
||||
|
||||
import ISummary from './isummary';
|
||||
|
||||
export default async (url: URL.Url) => {
|
||||
export default async (url: URL.Url): Promise<ISummary> => {
|
||||
const res = await client.fetch(url.href);
|
||||
|
||||
if (res.error) {
|
||||
|
@ -13,7 +13,7 @@ import general from './general';
|
||||
// Load builtin plugins
|
||||
const builtinPlugins = requireAll({
|
||||
dirname: __dirname + '/plugins'
|
||||
}) as IPlugin[];
|
||||
}) as { [key: string]: IPlugin };
|
||||
|
||||
export interface IOptions {
|
||||
/**
|
||||
@ -41,7 +41,7 @@ export default async (url: string, options: IOptions): Promise<Result> => {
|
||||
const opts = Object.assign({
|
||||
followRedirects: true,
|
||||
plugins: null
|
||||
}, options);
|
||||
}, options) as IOptions;
|
||||
|
||||
const plugins = Object.keys(builtinPlugins)
|
||||
.map(key => builtinPlugins[key])
|
||||
@ -53,9 +53,7 @@ export default async (url: string, options: IOptions): Promise<Result> => {
|
||||
const _url = URL.parse(actualUrl, true);
|
||||
|
||||
// Find matching plugin
|
||||
const match = Object.keys(plugins)
|
||||
.map(key => plugins[key])
|
||||
.filter(plugin => plugin.test(_url))[0] as IPlugin;
|
||||
const match = plugins.filter(plugin => plugin.test(_url))[0];
|
||||
|
||||
// Get summary
|
||||
const summary = match
|
||||
|
Reference in New Issue
Block a user