Skip to content

Commit 3ca2b99

Browse files
committed
fix(CRC-219): Do not add attachments of external images
1 parent de8051a commit 3ca2b99

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

components/markdown-confluence-sync/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,8 @@ This method starts the sync process. It returns a promise that resolves when the
535535

536536
### Testing images with absolute urls
537537

538+
[![image](https://download.logo.wine/logo/Markdown/Markdown-Logo.wine.png)](https://download.logo.wine/logo/Markdown/Markdown-Logo.wine.png)
539+
538540
### Testing local image
539541

540542
![image](./test-image.png)

components/markdown-confluence-sync/src/lib/confluence/transformer/support/rehype/rehype-add-attachments-images.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ import { visit } from "unist-util-visit";
99

1010
import type { ImagesMetadata } from "./rehype-add-attachments-images.types.js";
1111

12-
function isImage(node: HastElement): boolean {
12+
function isLocalImage(node: HastElement): boolean {
1313
return (
1414
node.tagName.toLowerCase() === "img" &&
1515
node.properties != null &&
16-
"src" in node.properties
16+
"src" in node.properties &&
17+
typeof node.properties.src === "string" &&
18+
!node.properties.src.startsWith("http")
1719
);
1820
}
1921

@@ -26,7 +28,7 @@ const rehypeAddAttachmentsImages: UnifiedPlugin<[], Root> =
2628
const images: ImagesMetadata = {};
2729

2830
visit(tree, "element", function (node) {
29-
if (isImage(node)) {
31+
if (isLocalImage(node)) {
3032
const base = file.dirname
3133
? path.resolve(file.cwd, file.dirname)
3234
: file.cwd;

0 commit comments

Comments
 (0)