Merge branch 'develop' of https://github.com/syuilo/misskey into develop

This commit is contained in:
syuilo 2020-11-08 11:25:31 +09:00
commit 0866d5c055
3 changed files with 43 additions and 3 deletions

View file

@ -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;

View file

@ -36,4 +36,5 @@ export function createTree(type: string, children: MfmForest, props: any): MfmTr
return T.createTree({ type, props }, children);
}
export const urlRegex = /^https?:\/\/[\w\/:%#@$&?!()\[\]~.,=+\-]+/;
export const urlRegex = /^https?:\/\/[\w\/:%#@$&?!()\[\]~.,=+\-]+/;
export const urlRegexFull = /^https?:\/\/[\w\/:%#@$&?!()\[\]~.,=+\-]+$/;