From f4cd0aeb6919bbb5a3ca27b7d6f295427e75998c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=BD=E5=AE=81?= <994718917@qq.com> Date: Tue, 9 May 2023 00:23:23 +0800 Subject: [PATCH] refactor: resolve duplicate function definitions (#2350) --- src/node/markdown/plugins/link.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/node/markdown/plugins/link.ts b/src/node/markdown/plugins/link.ts index cab9a6ea..d742f678 100644 --- a/src/node/markdown/plugins/link.ts +++ b/src/node/markdown/plugins/link.ts @@ -5,7 +5,7 @@ import type MarkdownIt from 'markdown-it' import type { MarkdownEnv } from '../env' import { URL } from 'url' -import { EXTERNAL_URL_RE, PATHNAME_PROTOCOL_RE } from '../../shared' +import { EXTERNAL_URL_RE, PATHNAME_PROTOCOL_RE, isExternal } from '../../shared' const indexRE = /(^|.*\/)index.md(#?.*)$/i @@ -26,8 +26,7 @@ export const linkPlugin = ( if (hrefIndex >= 0) { const hrefAttr = token.attrs![hrefIndex] const url = hrefAttr[1] - const isExternal = EXTERNAL_URL_RE.test(url) - if (isExternal) { + if (isExternal(url)) { Object.entries(externalAttrs).forEach(([key, val]) => { token.attrSet(key, val) })