Skip to content

Commit dc9fa7a

Browse files
committed
perf(remove-redirect): 使用 attribute 配置项简化站点配置
1 parent 02c2e48 commit dc9fa7a

3 files changed

Lines changed: 7 additions & 14 deletions

File tree

.changeset/stale-tools-tan.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'remove-redirect': patch
3+
---
4+
5+
使用 `attribute` 配置项简化站点配置

packages/remove-redirect/src/sites/bookmarkearth.cn.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { validateUrl } from '@femm/shared-utils'
21
import { defineSite } from 'src/utils'
32

43
/******************************************************************************
@@ -13,12 +12,7 @@ const sites = [
1312
{
1413
transform: {
1514
selector: 'a[href*="/view/"][data-ext]',
16-
customTransform(node) {
17-
const originUrl = decodeURIComponent(node.getAttribute('data-ext') || '')
18-
if (validateUrl(originUrl)) {
19-
node.href = originUrl
20-
}
21-
},
15+
attribute: 'data-ext',
2216
},
2317
autojump: {
2418
validator: ({ pathname }) =>

packages/remove-redirect/src/sites/so.com.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { validateUrl } from '@femm/shared-utils'
21
import { defineSite } from 'src/utils'
32

43
/******************************************************************************
@@ -14,12 +13,7 @@ const sites = [
1413
{
1514
transform: {
1615
selector: 'a[href*="so.com/link?"][data-mdurl]',
17-
customTransform(node) {
18-
const originUrl = node.getAttribute('data-mdurl')
19-
if (validateUrl(originUrl)) {
20-
node.setAttribute('href', originUrl!)
21-
}
22-
},
16+
attribute: 'data-mdurl',
2317
},
2418
},
2519
]),

0 commit comments

Comments
 (0)