From 32ea9b7274f54c29fdec1782b9c51419f6c74a6d Mon Sep 17 00:00:00 2001 From: Harry Liu Date: Sat, 10 Aug 2019 15:04:30 -0700 Subject: [PATCH] Add web UI redirection --- bin/build.sh | 7 ------- src/background.ts | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 11 deletions(-) delete mode 100755 bin/build.sh diff --git a/bin/build.sh b/bin/build.sh deleted file mode 100755 index 715678a..0000000 --- a/bin/build.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -rm -rf build -mkdir build -yarn -tsc -cp manifest.json build \ No newline at end of file diff --git a/src/background.ts b/src/background.ts index 361b506..efa4c3a 100644 --- a/src/background.ts +++ b/src/background.ts @@ -24,7 +24,8 @@ function extractAlias(shortLink: string): string { } class ShortExt { - constructor(private apiBaseUrl: string) {} + constructor(private apiBaseUrl: string, private webUi: string) { + } redirect = (details: Details): BlockingResponse => { let shortLink = details.url; @@ -34,9 +35,13 @@ class ShortExt { } let alias = extractAlias(shortLink); - + if (alias) { + return { + redirectUrl: `${this.apiBaseUrl}${alias}` + }; + } return { - redirectUrl: `${this.apiBaseUrl}${alias}` + redirectUrl: `${this.webUi}` }; }; @@ -63,5 +68,8 @@ class ShortExt { } } -const ext = new ShortExt('http://localhost/r/'); +const webUi = 'https://s.time4hacks.com'; +const apiBaseUrl = `${webUi}/r/`; + +const ext = new ShortExt(apiBaseUrl, webUi); ext.launch(); \ No newline at end of file