aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-04-09 12:11:11 +0300
committereug-vs <eug-vs@keemail.me>2020-04-09 12:11:11 +0300
commit6d36ca60373f4d89d79209d0c6324d6eda5a001d (patch)
treed60612656fd40c6b41461ad70fa76987fb44c311
parentb74897afe41962312828ffd362b7dd5ee8336775 (diff)
downloadreact-benzin-6d36ca60373f4d89d79209d0c6324d6eda5a001d.tar.gz
fix: correct linting errors
-rw-r--r--src/lib/Markdown/Markdown.tsx4
1 files changed, 2 insertions, 2 deletions
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<PropTypes> = ({ 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 <Section rawLines={lines} />
};