Skip to content

Commit 0eb6607

Browse files
authored
Merge pull request #11 from BBlackwo/dev-bblackwo-only-update-relative-images
fix(article): only update links for relative images
2 parents 1d7a972 + a1acabd commit 0eb6607

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/article.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,9 @@ describe(`Article`, () => {
3939
`Image 3: ![alt text 3](https://raw.githubusercontent.com/${repository.username}/${repository.name}/master/test/image-3.png)`,
4040
);
4141
});
42+
43+
it(`should NOT rewrite absolute images URLs to match the raw file on github`, () => {
44+
expect(articleRead).toContain(`Absolute image: ![alt text](http://google.com/absolute-image.png)`);
45+
});
4246
});
4347
});

src/article.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface ArticleFrontMatter {
77
title: string;
88
}
99

10-
const imagesRe: RegExp = /\!\[.*\]\(.*\)/g;
10+
const imagesRe: RegExp = /\!\[.*\]\(\.\/.*\)/g;
1111
const imageRe: RegExp = /\!\[(.*)\]\(([^ \)]*)(?: '(.*)')?\)/;
1212

1313
const excludeArticleFromPath = (path: string): string => path.replace(/\/[^\/]+\.md$/, '');

test/article.md

+6
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@ canonical_url:
99

1010
# This is my awesome article!
1111

12+
## Relative images
13+
1214
Hey, some text!
1315

1416
Image 1: ![alt text 1](./image-1.png 'Title image 1')
1517

1618
Image 2: ![alt text 2](./image-2.png 'Title image 2')
1719

1820
Image 3: ![alt text 3](./image-3.png)
21+
22+
## Absolute images
23+
24+
Absolute image: ![alt text](http://google.com/absolute-image.png)

0 commit comments

Comments
 (0)