mirror of
https://github.com/misskey-dev/summaly.git
synced 2025-04-29 02:37:27 +09:00
fix: branch.ioを用いたディープリンクをパースできるように修正 (#13)
* (fix) branch.ioのディープリンクでうまく作動しないのを修正 * Update changelog * fix regex
This commit is contained in:
parent
d2d8db4994
commit
d2a3e07205
@ -1,3 +1,7 @@
|
||||
4.x.x (Unreleased) / 2023-09-xx
|
||||
------------------
|
||||
* branch.ioを用いたディープリンク(spotify.link)などでパースに失敗する問題を修正
|
||||
|
||||
4.0.2 / 2023-04-20
|
||||
------------------
|
||||
* YouTubeをフルスクリーンにできない問題を修正
|
||||
|
2
built/iplugin.d.ts
vendored
2
built/iplugin.d.ts
vendored
@ -3,5 +3,5 @@ import type { URL } from 'node:url';
|
||||
import Summary from './summary.js';
|
||||
export interface IPlugin {
|
||||
test: (url: URL) => boolean;
|
||||
summarize: (url: URL, lang?: string) => Promise<Summary>;
|
||||
summarize: (url: URL, lang?: string) => Promise<Summary | null>;
|
||||
}
|
||||
|
5
built/plugins/branchio-deeplinks.d.ts
vendored
Normal file
5
built/plugins/branchio-deeplinks.d.ts
vendored
Normal file
@ -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>;
|
12
built/plugins/branchio-deeplinks.js
Normal file
12
built/plugins/branchio-deeplinks.js
Normal file
@ -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);
|
||||
}
|
@ -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,
|
||||
];
|
||||
|
@ -3,5 +3,5 @@ import Summary from './summary.js';
|
||||
|
||||
export interface IPlugin {
|
||||
test: (url: URL) => boolean;
|
||||
summarize: (url: URL, lang?: string) => Promise<Summary>;
|
||||
summarize: (url: URL, lang?: string) => Promise<Summary | null>;
|
||||
}
|
||||
|
19
src/plugins/branchio-deeplinks.ts
Normal file
19
src/plugins/branchio-deeplinks.ts
Normal file
@ -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);
|
||||
}
|
@ -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,
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user