From b1c6c0442ffeecd9153c030eea669f19d73accce Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Tue, 29 Jan 2019 16:49:51 +0100 Subject: [PATCH] fix guardrails errors --- browser/components/CodeEditor.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js index 01a54aac..6ad294ed 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -888,10 +888,7 @@ export default class CodeEditor extends React.Component { handlePaste (editor, forceSmartPaste) { const { storageKey, noteKey, fetchUrlTitle, enableSmartPaste } = this.props - const isURL = str => { - const matcher = /^(?:\w+:)?\/\/([^\s\.]+\.\S{2}|localhost[\:?\d]*)\S*$/ - return matcher.test(str) - } + const isURL = str => /(?:^\w+:|^)\/\/(?:[^\s\.]+\.\S{2}|localhost[\:?\d]*)/.test(str) const isInLinkTag = editor => { const startCursor = editor.getCursor('start') @@ -1109,7 +1106,7 @@ export default class CodeEditor extends React.Component { iconv.encodingExists(_charset) ? _charset : 'utf-8' - resolve(iconv.decode(new Buffer(buff), charset).toString()) + resolve(iconv.decode(Buffer.from(buff), charset).toString()) } catch (e) { reject(e) }