From e94dd8a5e808786b89adb55939c9e8ac2dd3f691 Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Fri, 27 Sep 2019 04:59:40 +0900 Subject: [PATCH] Refactor removal of trailing comma/period (#5434) * Refactor removal of trailing comma/period * Use regex --- src/mfm/language.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/mfm/language.ts b/src/mfm/language.ts index 5faa08fd9..c5cdb5e3e 100644 --- a/src/mfm/language.ts +++ b/src/mfm/language.ts @@ -167,10 +167,7 @@ export const mfmLanguage = P.createLanguage({ url = match[0]; } url = removeOrphanedBrackets(url); - while (url.endsWith('.') || url.endsWith(',')) { - if (url.endsWith('.')) url = url.substr(0, url.lastIndexOf('.')); - if (url.endsWith(',')) url = url.substr(0, url.lastIndexOf(',')); - } + url = url.replace(/[.,]*$/, ''); return P.makeSuccess(i + url.length, url); }).map(x => createLeaf('url', { url: x })); },