From c37e0f38315e39665b7943bb2ad14e27d4a9812e Mon Sep 17 00:00:00 2001 From: otofune Date: Sat, 28 Jan 2017 04:38:44 +0900 Subject: [PATCH] check redirection resolve #5. --- package.json | 3 ++- src/index.ts | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 161b56b..dffef2e 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/src/index.ts b/src/index.ts index eaa3bef..3d829a0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 => { - 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];