forked from syuilo/summaly
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: branch.ioを用いたディープリンクをパースできるように修正 (#13)
* (fix) branch.ioのディープリンクでうまく作動しないのを修正 * Update changelog * fix regex
- Loading branch information
1 parent
d2d8db4
commit d2a3e07
Showing
8 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/// <reference types="node" /> | ||
import { URL } from 'node:url'; | ||
import Summary from '../summary.js'; | ||
export declare function test(url: URL): boolean; | ||
export declare function summarize(url: URL, lang?: string | null): Promise<Summary | null>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import general from '../general.js'; | ||
export function test(url) { | ||
// Branch.io を使用したディープリンクにマッチ | ||
return /^[a-zA-Z0-9]+\.app\.link$/.test(url.hostname) || | ||
url.hostname === 'spotify.link'; | ||
} | ||
export async function summarize(url, lang = null) { | ||
// https://help.branch.io/using-branch/docs/creating-a-deep-link#redirections | ||
// Web版に強制リダイレクトすることでbranch.ioの独自ページが開くのを防ぐ | ||
url.searchParams.append('$web_only', 'true'); | ||
return await general(url, lang); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import * as amazon from './amazon.js'; | ||
import * as wikipedia from './wikipedia.js'; | ||
import * as branchIoDeeplinks from './branchio-deeplinks.js'; | ||
export const plugins = [ | ||
amazon, | ||
wikipedia, | ||
branchIoDeeplinks, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { URL } from 'node:url'; | ||
import { scpaping } from '../utils/got.js'; | ||
import general from '../general.js'; | ||
import Summary from '../summary.js'; | ||
|
||
export function test(url: URL): boolean { | ||
// Branch.io を使用したディープリンクにマッチ | ||
return /^[a-zA-Z0-9]+\.app\.link$/.test(url.hostname) || | ||
url.hostname === 'spotify.link'; | ||
} | ||
|
||
export async function summarize(url: URL, lang: string | null = null): Promise<Summary | null> { | ||
|
||
// https://help.branch.io/using-branch/docs/creating-a-deep-link#redirections | ||
// Web版に強制リダイレクトすることでbranch.ioの独自ページが開くのを防ぐ | ||
url.searchParams.append('$web_only', 'true'); | ||
|
||
return await general(url, lang); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import { IPlugin } from '@/iplugin.js'; | ||
import * as amazon from './amazon.js'; | ||
import * as wikipedia from './wikipedia.js'; | ||
import * as branchIoDeeplinks from './branchio-deeplinks.js'; | ||
|
||
export const plugins: IPlugin[] = [ | ||
amazon, | ||
wikipedia, | ||
branchIoDeeplinks, | ||
]; |