Skip to content

Commit ca486ed

Browse files
committed
fix: 修复在处理当前页面的完整路径时url的跳转行为
1 parent 2590242 commit ca486ed

File tree

1 file changed

+6
-1
lines changed
  • client/web/plugins/com.msgbyte.bbcode/src/tags

1 file changed

+6
-1
lines changed

client/web/plugins/com.msgbyte.bbcode/src/tags/UrlTag.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ export const UrlTag: React.FC<TagProps> = React.memo((props) => {
77
const text = node.content.join('');
88
const url = node.attrs.url ?? text;
99

10-
if (url.startsWith('/') || url.startsWith(window.location.origin)) {
10+
if (url.startsWith('/')) {
1111
// 内部地址,使用 react-router 进行导航
1212
return <Link to={url}>{text}</Link>;
1313
}
1414

15+
if (url.startsWith(window.location.origin)) {
16+
// 内部地址,使用 react-router 进行导航
17+
return <Link to={url.replace(window.location.origin, '')}>{text}</Link>;
18+
}
19+
1520
return (
1621
<a href={url} title={text} target="_blank" rel="noopener noreferrer">
1722
{text}

0 commit comments

Comments
 (0)