リモートユーザーのHTMLで表現されたプロフィールをMFMに変換するように
This commit is contained in:
20
src/mfm/parse/elements/url.ts
Normal file
20
src/mfm/parse/elements/url.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* URL
|
||||
*/
|
||||
|
||||
export type TextElementUrl = {
|
||||
type: 'url'
|
||||
content: string
|
||||
url: string
|
||||
};
|
||||
|
||||
export default function(text: string) {
|
||||
const match = text.match(/^https?:\/\/[\w\/:%#@\$&\?!\(\)\[\]~\.=\+\-]+/);
|
||||
if (!match) return null;
|
||||
const url = match[0];
|
||||
return {
|
||||
type: 'url',
|
||||
content: url,
|
||||
url: url
|
||||
} as TextElementUrl;
|
||||
}
|
Reference in New Issue
Block a user