Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 6eea6d1

Browse files
committed
fix(plugins/plugin-client-common): replay against files with relative image links fail to load image
1 parent 931235d commit 6eea6d1

File tree

1 file changed

+6
-4
lines changed
  • plugins/plugin-client-common/src/components/Content/Markdown/components

1 file changed

+6
-4
lines changed

plugins/plugin-client-common/src/components/Content/Markdown/components/img.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,18 @@ function allContentIsRemote(props: Props): boolean {
3333
function handleImage(mdprops: Props, props: ImgProps, key?: string) {
3434
let { src } = props
3535

36-
const isHttp = /^http/i.test(src)
36+
const baseUrlIsHttp = mdprops.baseUrl && /http/i.test(mdprops.baseUrl)
37+
const srcIsHttp = /^http/i.test(src)
38+
const isHttp = srcIsHttp || baseUrlIsHttp
3739
const isLocal = !isHttp && !allContentIsRemote(mdprops)
40+
3841
if (isLocal) {
3942
const absoluteSrc = isAbsolute(src)
4043
? src
4144
: join(mdprops.fullpath ? dirname(mdprops.fullpath) : mdprops.baseUrl || process.cwd(), src)
4245
src = absoluteSrc
43-
} else if (!isHttp && mdprops.baseUrl) {
44-
// then this is a relative path against
45-
src = `${mdprops.baseUrl}${!/\/$/.test(mdprops.baseUrl) ? '/' : ''}${src}`
46+
} else if (!srcIsHttp && mdprops.baseUrl) {
47+
src = mdprops.baseUrl.replace(/{filename}/g, src)
4648
}
4749

4850
const style = props && props.align ? { float: props.align } : undefined

0 commit comments

Comments
 (0)