Skip to content

Commit 7e16ed7

Browse files
authoredJul 15, 2022
fix: support fragments in image URLs (#753)
* fix: make tests fail * fix: support hash character in URLs
1 parent 955c760 commit 7e16ed7

12 files changed

+23
-1
lines changed
 

‎src/package.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ export class MarkdownProcessor extends BaseProcessor {
709709
contents = contents.replace(markdownPathRegex, urlReplace);
710710

711711
// Replace <img> links with urls
712-
contents = contents.replace(/<img.+?src=["']([/.\w\s-]+)['"].*?>/g, (all, link) => {
712+
contents = contents.replace(/<img.+?src=["']([/.\w\s#-]+)['"].*?>/g, (all, link) => {
713713
const isLinkRelative = !/^\w+:\/\//.test(link) && link[0] !== '#';
714714

715715
if (!this.baseImagesUrl && isLinkRelative) {

‎src/test/fixtures/readme/readme.branch.main.expected.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ The status bar lets you quickly navigate to any issue and you can see all positi
2222
[![Jump to issues](https://github.com/username/repository/raw/main/images/SpellMDDemo2.gif)](https://github.com/username/repository/blob/main/monkey)
2323
![](https://github.com/username/repository/raw/main/images/SpellMDDemo2.gif)
2424
![](https://github.com/username/repository/raw/main/SpellMDDemo2.gif)
25+
![](https://github.com/username/repository/raw/main/SpellMDDemo2.gif#gh-light-mode-only)
2526
<img src="https://github.com/username/repository/raw/main/images/myImage.gif">
27+
<img src="https://github.com/username/repository/raw/main/images/myImage.gif#gh-light-mode-only">
2628

2729
The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.
2830

‎src/test/fixtures/readme/readme.branch.override.content.expected.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ The status bar lets you quickly navigate to any issue and you can see all positi
2222
[![Jump to issues](https://github.com/base/images/SpellMDDemo2.gif)](https://github.com/base/monkey)
2323
![](https://github.com/base/images/SpellMDDemo2.gif)
2424
![](https://github.com/base/SpellMDDemo2.gif)
25+
![](https://github.com/base/SpellMDDemo2.gif#gh-light-mode-only)
2526
<img src="https://github.com/base/images/myImage.gif">
27+
<img src="https://github.com/base/images/myImage.gif#gh-light-mode-only">
2628

2729
The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.
2830

‎src/test/fixtures/readme/readme.branch.override.images.expected.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ The status bar lets you quickly navigate to any issue and you can see all positi
2222
[![Jump to issues](https://github.com/base/images/SpellMDDemo2.gif)](https://github.com/username/repository/blob/main/monkey)
2323
![](https://github.com/base/images/SpellMDDemo2.gif)
2424
![](https://github.com/base/SpellMDDemo2.gif)
25+
![](https://github.com/base/SpellMDDemo2.gif#gh-light-mode-only)
2526
<img src="https://github.com/base/images/myImage.gif">
27+
<img src="https://github.com/base/images/myImage.gif#gh-light-mode-only">
2628

2729
The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.
2830

‎src/test/fixtures/readme/readme.default.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ The status bar lets you quickly navigate to any issue and you can see all positi
2222
[![Jump to issues](https://github.com/username/repository/raw/HEAD/images/SpellMDDemo2.gif)](https://github.com/username/repository/blob/HEAD/monkey)
2323
![](https://github.com/username/repository/raw/HEAD/images/SpellMDDemo2.gif)
2424
![](https://github.com/username/repository/raw/HEAD/SpellMDDemo2.gif)
25+
![](https://github.com/username/repository/raw/HEAD/SpellMDDemo2.gif#gh-light-mode-only)
2526
<img src="https://github.com/username/repository/raw/HEAD/images/myImage.gif">
27+
<img src="https://github.com/username/repository/raw/HEAD/images/myImage.gif#gh-light-mode-only">
2628

2729
The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.
2830

‎src/test/fixtures/readme/readme.expected.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ The status bar lets you quickly navigate to any issue and you can see all positi
2222
[![Jump to issues](https://github.com/username/repository/raw/master/images/SpellMDDemo2.gif)](https://github.com/username/repository/blob/master/monkey)
2323
![](https://github.com/username/repository/raw/master/images/SpellMDDemo2.gif)
2424
![](https://github.com/username/repository/raw/master/SpellMDDemo2.gif)
25+
![](https://github.com/username/repository/raw/master/SpellMDDemo2.gif#gh-light-mode-only)
2526
<img src="https://github.com/username/repository/raw/master/images/myImage.gif">
27+
<img src="https://github.com/username/repository/raw/master/images/myImage.gif#gh-light-mode-only">
2628

2729
The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.
2830

‎src/test/fixtures/readme/readme.gitlab.branch.main.expected.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ The status bar lets you quickly navigate to any issue and you can see all positi
2222
[![Jump to issues](https://gitlab.com/username/repository/-/raw/main/images/SpellMDDemo2.gif)](https://gitlab.com/username/repository/-/blob/main/monkey)
2323
![](https://gitlab.com/username/repository/-/raw/main/images/SpellMDDemo2.gif)
2424
![](https://gitlab.com/username/repository/-/raw/main/SpellMDDemo2.gif)
25+
![](https://gitlab.com/username/repository/-/raw/main/SpellMDDemo2.gif#gh-light-mode-only)
2526
<img src="https://gitlab.com/username/repository/-/raw/main/images/myImage.gif">
27+
<img src="https://gitlab.com/username/repository/-/raw/main/images/myImage.gif#gh-light-mode-only">
2628

2729
The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.
2830

‎src/test/fixtures/readme/readme.gitlab.branch.override.content.expected.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ The status bar lets you quickly navigate to any issue and you can see all positi
2222
[![Jump to issues](https://gitlab.com/base/images/SpellMDDemo2.gif)](https://gitlab.com/base/monkey)
2323
![](https://gitlab.com/base/images/SpellMDDemo2.gif)
2424
![](https://gitlab.com/base/SpellMDDemo2.gif)
25+
![](https://gitlab.com/base/SpellMDDemo2.gif#gh-light-mode-only)
2526
<img src="https://gitlab.com/base/images/myImage.gif">
27+
<img src="https://gitlab.com/base/images/myImage.gif#gh-light-mode-only">
2628

2729
The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.
2830

‎src/test/fixtures/readme/readme.gitlab.branch.override.images.expected.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ The status bar lets you quickly navigate to any issue and you can see all positi
2222
[![Jump to issues](https://gitlab.com/base/images/SpellMDDemo2.gif)](https://gitlab.com/username/repository/-/blob/main/monkey)
2323
![](https://gitlab.com/base/images/SpellMDDemo2.gif)
2424
![](https://gitlab.com/base/SpellMDDemo2.gif)
25+
![](https://gitlab.com/base/SpellMDDemo2.gif#gh-light-mode-only)
2526
<img src="https://gitlab.com/base/images/myImage.gif">
27+
<img src="https://gitlab.com/base/images/myImage.gif#gh-light-mode-only">
2628

2729
The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.
2830

‎src/test/fixtures/readme/readme.gitlab.default.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ The status bar lets you quickly navigate to any issue and you can see all positi
2222
[![Jump to issues](https://gitlab.com/username/repository/-/raw/HEAD/images/SpellMDDemo2.gif)](https://gitlab.com/username/repository/-/blob/HEAD/monkey)
2323
![](https://gitlab.com/username/repository/-/raw/HEAD/images/SpellMDDemo2.gif)
2424
![](https://gitlab.com/username/repository/-/raw/HEAD/SpellMDDemo2.gif)
25+
![](https://gitlab.com/username/repository/-/raw/HEAD/SpellMDDemo2.gif#gh-light-mode-only)
2526
<img src="https://gitlab.com/username/repository/-/raw/HEAD/images/myImage.gif">
27+
<img src="https://gitlab.com/username/repository/-/raw/HEAD/images/myImage.gif#gh-light-mode-only">
2628

2729
The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.
2830

‎src/test/fixtures/readme/readme.images.expected.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ The status bar lets you quickly navigate to any issue and you can see all positi
2222
[![Jump to issues](https://github.com/username/repository/path/to/images/SpellMDDemo2.gif)](https://github.com/username/repository/blob/HEAD/monkey)
2323
![](https://github.com/username/repository/path/to/images/SpellMDDemo2.gif)
2424
![](https://github.com/username/repository/path/to/SpellMDDemo2.gif)
25+
![](https://github.com/username/repository/path/to/SpellMDDemo2.gif#gh-light-mode-only)
2526
<img src="https://github.com/username/repository/path/to/images/myImage.gif">
27+
<img src="https://github.com/username/repository/path/to/images/myImage.gif#gh-light-mode-only">
2628

2729
The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.
2830

‎src/test/fixtures/readme/readme.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ The status bar lets you quickly navigate to any issue and you can see all positi
2222
[![Jump to issues](images/SpellMDDemo2.gif)](monkey)
2323
![](images/SpellMDDemo2.gif)
2424
![](./SpellMDDemo2.gif)
25+
![](./SpellMDDemo2.gif#gh-light-mode-only)
2526
<img src="/images/myImage.gif">
27+
<img src="/images/myImage.gif#gh-light-mode-only">
2628

2729
The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.
2830

0 commit comments

Comments
 (0)
Please sign in to comment.