Add angle bracket covered url syntax to mfm (#4483)
* Add angle bracket covered url syntax to mfm * Fix path * Fix match * Fix index
This commit is contained in:

committed by
GitHub

parent
0f65b1bcc5
commit
38656103c0
@@ -1,5 +1,6 @@
|
||||
import { parseFragment, DefaultTreeDocumentFragment } from 'parse5';
|
||||
import { URL } from 'url';
|
||||
import { urlRegex } from './prelude';
|
||||
|
||||
export function fromHtml(html: string): string {
|
||||
if (html == null) return null;
|
||||
@@ -14,7 +15,7 @@ export function fromHtml(html: string): string {
|
||||
|
||||
return text.trim();
|
||||
|
||||
function getText(node: any) {
|
||||
function getText(node: any): string {
|
||||
if (node.nodeName == '#text') return node.value;
|
||||
|
||||
if (node.childNodes) {
|
||||
@@ -41,7 +42,7 @@ export function fromHtml(html: string): string {
|
||||
|
||||
// ハッシュタグ / hrefがない / txtがURL
|
||||
if ((rel && rel.value.match('tag') !== null) || !href || href.value == txt) {
|
||||
text += txt;
|
||||
text += txt.match(urlRegex) ? txt : `<${txt}>`;
|
||||
// メンション
|
||||
} else if (txt.startsWith('@') && !(rel && rel.value.match(/^me /))) {
|
||||
const part = txt.split('@');
|
||||
|
Reference in New Issue
Block a user