aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Markdown
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Markdown')
-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} />
};