diff options
| author | Akihiko Odaki <nekomanma@pixiv.co.jp> | 2018-03-31 19:53:30 +0900 |
|---|---|---|
| committer | Akihiko Odaki <nekomanma@pixiv.co.jp> | 2018-03-31 20:30:28 +0900 |
| commit | 7da60a0147116130a94274e4a20ae54dd7d59dea (patch) | |
| tree | 442514d76f90ede80906659b14d5f7bbc531d32a /src/common/text/parse/elements/link.ts | |
| parent | Set empty array instead of null to mediaIds property of posts (diff) | |
| download | misskey-7da60a0147116130a94274e4a20ae54dd7d59dea.tar.gz misskey-7da60a0147116130a94274e4a20ae54dd7d59dea.tar.bz2 misskey-7da60a0147116130a94274e4a20ae54dd7d59dea.zip | |
Store texts as HTML
Diffstat (limited to 'src/common/text/parse/elements/link.ts')
| -rw-r--r-- | src/common/text/parse/elements/link.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/common/text/parse/elements/link.ts b/src/common/text/parse/elements/link.ts new file mode 100644 index 0000000000..35563ddc3d --- /dev/null +++ b/src/common/text/parse/elements/link.ts @@ -0,0 +1,19 @@ +/** + * Link + */ + +module.exports = text => { + const match = text.match(/^\??\[([^\[\]]+?)\]\((https?:\/\/[\w\/:%#@\$&\?!\(\)\[\]~\.=\+\-]+?)\)/); + if (!match) return null; + const silent = text[0] == '?'; + const link = match[0]; + const title = match[1]; + const url = match[2]; + return { + type: 'link', + content: link, + title: title, + url: url, + silent: silent + }; +}; |