We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ca4692a commit d4f85d9Copy full SHA for d4f85d9
components/markdown/image.tsx
@@ -5,10 +5,14 @@ import { Box } from '@sparkpost/matchbox';
5
6
const getImageSrc = (asPath: string, src?: string) => {
7
const environment = getWindow();
8
- const parts = asPath.split('/');
9
- const dirArr = parts.splice(0, parts.length - 1);
10
- dirArr.pop();
11
- const dir = dirArr.join('/');
+ const pathArr = asPath.split('/');
+
+ // Check for 'trailing slash'
+ if (!pathArr[pathArr.length - 1]) {
12
+ pathArr.pop();
13
+ }
14
15
+ const dir = pathArr.join('/');
16
const path = `${environment?.location.origin || 'https://localhost:3000'}/content${dir}/${src}`;
17
return path;
18
};
0 commit comments