Merge pull request #6 from armchair-philosophy/feature/#5

follow redirection
This commit is contained in:
syuilo⭐️ 2017-01-28 09:13:36 +09:00 committed by GitHub
commit 25d9232ee2
2 changed files with 6 additions and 2 deletions

View File

@ -24,6 +24,7 @@
"cheerio-httpcli": "0.6.10",
"escape-regexp": "0.0.1",
"html-entities": "1.2.0",
"request": "2.79.0"
"request": "2.79.0",
"trace-redirect": "1.0.2-1"
}
}

View File

@ -1,4 +1,5 @@
import * as URL from 'url';
import tracer from 'trace-redirect';
import ISummary from './isummary';
import IPlugin from './iplugin';
import general from './general';
@ -9,7 +10,9 @@ const plugins: IPlugin[] = [
];
export default async (url: string): Promise<ISummary> => {
const _url = URL.parse(url, true);
const realUrl = await tracer(url);
const _url = URL.parse(realUrl, true);
const plugin = plugins.filter(plugin => plugin.test(_url))[0];