mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Simplify URL Rewrite and migrate to URL Redirect
This commit is contained in:
@@ -12,7 +12,7 @@ function escapeRegExp(string = '') {
|
||||
: string;
|
||||
}
|
||||
|
||||
const REDIRECT = [
|
||||
const REDIRECT_MIRROR = [
|
||||
// Gravatar
|
||||
['gravatar.neworld.org/', 'https://secure.gravatar.com/'],
|
||||
['cdn.v2ex.com/gravatar/', 'https://secure.gravatar.com/avatar/'],
|
||||
@@ -75,8 +75,58 @@ const REDIRECT = [
|
||||
['googleajax.wp-china-yes.net/', 'https://ajax.googleapis.com/']
|
||||
] as const;
|
||||
|
||||
const REDIRECT_FAKEWEBSITES = [
|
||||
// Redirect Google
|
||||
['google.cn', 'https://www.google.com'],
|
||||
// IGN China to IGN Global
|
||||
['ign.xn--fiqs8s', 'https://cn.ign.com/ccpref/us'],
|
||||
// Fuck Makeding
|
||||
['abbyychina.com', 'https://www.abbyy.cn'],
|
||||
['bartender.cc', 'https://cn.seagullscientific.com'],
|
||||
['betterzip.net', 'https://macitbetter.com'],
|
||||
['beyondcompare.cc', 'https://www.scootersoftware.com'],
|
||||
['bingdianhuanyuan.cn', 'https://www.faronics.com'],
|
||||
['chemdraw.com.cn', 'https://revvitysignals.com/products/research/chemdraw'],
|
||||
['codesoftchina.com', 'https://www.teklynx.com'],
|
||||
['coreldrawchina.com', 'https://www.coreldraw.com'],
|
||||
['crossoverchina.com', 'https://www.codeweavers.com'],
|
||||
['easyrecoverychina.com', 'https://www.ontrack.com'],
|
||||
['ediuschina.com', 'https://www.grassvalley.com'],
|
||||
['flstudiochina.com', 'https://www.image-line.com/fl-studio'],
|
||||
['formysql.com', 'https://www.navicat.com.cn'],
|
||||
['guitarpro.cc', 'https://www.guitar-pro.com'],
|
||||
['huishenghuiying.com.cn', 'https://www.corel.com'],
|
||||
['iconworkshop.cn', 'https://www.axialis.com/iconworkshop'],
|
||||
['imindmap.cc', 'https://imindmap.com/zh-cn'],
|
||||
['jihehuaban.com.cn', 'https://sketch.io'],
|
||||
['keyshot.cc', 'https://www.keyshot.com'],
|
||||
['mathtype.cn', 'https://www.wiris.com/en/mathtype'],
|
||||
['mindmanager.cc', 'https://www.mindjet.com'],
|
||||
['mindmapper.cc', 'https://mindmapper.com'],
|
||||
['mycleanmymac.com', 'https://macpaw.com/cleanmymac'],
|
||||
['nicelabel.cc', 'https://www.nicelabel.com'],
|
||||
['ntfsformac.cc', 'https://www.tuxera.com/products/tuxera-ntfs-for-mac-cn'],
|
||||
['ntfsformac.cn', 'https://www.paragon-software.com/ufsdhome/zh/ntfs-mac'],
|
||||
['overturechina.com', 'https://sonicscores.com/overture'],
|
||||
['passwordrecovery.cn', 'https://cn.elcomsoft.com/aopr.html'],
|
||||
['pdfexpert.cc', 'https://pdfexpert.com/zh'],
|
||||
['ultraiso.net', 'https://cn.ezbsystems.com/ultraiso'],
|
||||
['vegaschina.cn', 'https://www.vegas.com'],
|
||||
['xmindchina.net', 'https://www.xmind.cn'],
|
||||
['xshellcn.com', 'https://www.netsarang.com/products/xsh_overview.html'],
|
||||
['yuanchengxiezuo.com', 'https://www.teamviewer.com/zhcn'],
|
||||
['zbrushcn.com', 'https://www.maxon.net/en/zbrush']
|
||||
] as const;
|
||||
|
||||
export const buildRedirectModule = task(import.meta.path, async (span) => {
|
||||
const domains = Array.from(new Set(REDIRECT.map(([from]) => tldts.getHostname(from, { detectIp: false })))).filter(Boolean);
|
||||
const domains = Array.from(
|
||||
new Set(
|
||||
[
|
||||
...REDIRECT_MIRROR.map(([from]) => tldts.getHostname(from, { detectIp: false })),
|
||||
...REDIRECT_FAKEWEBSITES.flatMap(([from]) => [from, `www.${from}`])
|
||||
]
|
||||
)
|
||||
).filter(Boolean);
|
||||
|
||||
return compareAndWriteFile(
|
||||
span,
|
||||
@@ -88,7 +138,8 @@ export const buildRedirectModule = task(import.meta.path, async (span) => {
|
||||
`hostname = %APPEND% ${domains.join(', ')}`,
|
||||
'',
|
||||
'[URL Rewrite]',
|
||||
...REDIRECT.map(([from, to]) => `^https?://${escapeRegExp(from)}(.*) ${to}$1 302`)
|
||||
...REDIRECT_MIRROR.map(([from, to]) => `^https?://${escapeRegExp(from)}(.*) ${to}$1`),
|
||||
...REDIRECT_FAKEWEBSITES.map(([from, to]) => `^https?://(www.)?${escapeRegExp(from)} ${to}`)
|
||||
],
|
||||
path.resolve(import.meta.dir, '../Modules/sukka_url_redirect.sgmodule')
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user