diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2020-11-08 00:38:50 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-08 00:38:50 +0900 |
| commit | 27d0ac3d750f82888703c707ff2bf54db2531a67 (patch) | |
| tree | 0be3f8f449c8573862c263c16e4e8e7111b0d10e /src/mfm/from-html.ts | |
| parent | Improve readability (diff) | |
| download | misskey-27d0ac3d750f82888703c707ff2bf54db2531a67.tar.gz misskey-27d0ac3d750f82888703c707ff2bf54db2531a67.tar.bz2 misskey-27d0ac3d750f82888703c707ff2bf54db2531a67.zip | |
In HTML to MFM, use angle bracket if needed (#6817)
Diffstat (limited to 'src/mfm/from-html.ts')
| -rw-r--r-- | src/mfm/from-html.ts | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/mfm/from-html.ts b/src/mfm/from-html.ts index 1eca3fc6ce..4c27c2cbba 100644 --- a/src/mfm/from-html.ts +++ b/src/mfm/from-html.ts @@ -1,5 +1,5 @@ import { parseFragment, DefaultTreeDocumentFragment } from 'parse5'; -import { urlRegex } from './prelude'; +import { urlRegexFull } from './prelude'; export function fromHtml(html: string, hashtagNames?: string[]): string { const dom = parseFragment(html) as DefaultTreeDocumentFragment; @@ -54,7 +54,11 @@ export function fromHtml(html: string, hashtagNames?: string[]): string { } // その他 } else { - text += (!href || (txt === href.value && txt.match(urlRegex))) ? txt : `[${txt}](${href.value})`; + text += !href ? txt + : txt === href.value + ? txt.match(urlRegexFull) ? txt + : `<${txt}>` + : `[${txt}](${href.value})`; } break; |