From b3e37dd2c10612c288e4c7d87ba9ea02a886cf6b Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Thu, 23 Sep 2021 01:01:02 -0500 Subject: [PATCH] add comment about trying capture groups in future. --- shared/naturalcrit/codeEditor/codeEditor.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index f49cd29b1..c39c43da2 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -105,8 +105,8 @@ const CodeEditor = createClass({ const isLink = /^\[(.*)(\]\()(.*)\)$/g; const selection = this.codeMirror.getSelection(); if(isLink.test(selection) == true){ - const altText = selection.slice(1, selection.lastIndexOf('](')); - const url = selection.slice(selection.lastIndexOf('](') + 2, -1); + const altText = selection.slice(1, selection.lastIndexOf('](')); // could likely be done better with capture groups + const url = selection.slice(selection.lastIndexOf('](') + 2, -1); // could likely be done better with capture groups this.codeMirror.replaceSelection(`${altText} ${url}`); const cursor = this.codeMirror.getCursor(); this.codeMirror.setSelection({ line: cursor.line, ch: cursor.ch - url.length }, { line: cursor.line, ch: cursor.ch });