From 6d36ca60373f4d89d79209d0c6324d6eda5a001d Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 9 Apr 2020 12:11:11 +0300 Subject: fix: correct linting errors --- src/lib/Markdown/Markdown.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib/Markdown/Markdown.tsx b/src/lib/Markdown/Markdown.tsx index c929c71..82e889c 100644 --- a/src/lib/Markdown/Markdown.tsx +++ b/src/lib/Markdown/Markdown.tsx @@ -8,7 +8,7 @@ interface PropTypes { url?: string; } -const resolveUrls = (line: string, baseUrl: string = ''): string => { +const resolveUrls = (line: string, baseUrl: string): string => { return line.replace(/src="(?!http)(.*)"[\s>]/, (match, url, offset, string) => `src="${baseUrl}/${url}?sanitize=true"`) .replace(/\[(.*\]?.*)\]\((?!http)(.+?)\)/, (match, text, url, offset, string) => `[${text}](${baseUrl}/${url})`); } @@ -22,7 +22,7 @@ const Markdown: React.FC = ({ data, url }) => { if (!url) setMarkdown(data || ''); }, [data, url]); - const baseUrl = url?.slice(0, url.lastIndexOf('/')); + const baseUrl = url?.slice(0, url.lastIndexOf('/')) || ''; const lines = markdown.split(/\r?\n/).map(line => resolveUrls(line, baseUrl)); return
}; -- cgit v1.2.3