summaryrefslogtreecommitdiff
path: root/src/mfm/language.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/mfm/language.ts')
-rw-r--r--src/mfm/language.ts15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/mfm/language.ts b/src/mfm/language.ts
index 60e4935ed2..7b083b99af 100644
--- a/src/mfm/language.ts
+++ b/src/mfm/language.ts
@@ -1,5 +1,5 @@
import * as P from 'parsimmon';
-import { createLeaf, createTree } from './types';
+import { createLeaf, createTree, urlRegex } from './prelude';
import { takeWhile, cumulativeSum } from '../prelude/array';
import parseAcct from '../misc/acct/parse';
import { toUnicode } from 'punycode';
@@ -154,9 +154,16 @@ export const mfmLanguage = P.createLanguage({
url: () => {
return P((input, i) => {
const text = input.substr(i);
- const match = text.match(/^https?:\/\/[\w\/:%#@\$&\?!\(\)\[\]~\.,=\+\-]+/);
- if (!match) return P.makeFailure(i, 'not a url');
- let url = match[0];
+ const match = text.match(urlRegex);
+ let url: string;
+ if (!match) {
+ const match = text.match(/^<(https?:\/\/.*?)>/);
+ if (!match)
+ return P.makeFailure(i, 'not a url');
+ url = match[1];
+ i += 2;
+ } else
+ url = match[0];
url = removeOrphanedBrackets(url);
if (url.endsWith('.')) url = url.substr(0, url.lastIndexOf('.'));
if (url.endsWith(',')) url = url.substr(0, url.lastIndexOf(','));