Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support fragments in image URLs #753

Merged
merged 2 commits into from Jul 15, 2022
Merged

fix: support fragments in image URLs #753

merged 2 commits into from Jul 15, 2022

Conversation

nhedger
Copy link
Contributor

@nhedger nhedger commented Jul 9, 2022

This PR fixes #739 by taking the # character into account in image URLs.

Description

When inserting images in a markdown file using the HTML tag, relative image URLs that contain a # character do not get prefixed with the base URL.

<img src="/images/myImage.gif#gh-light-mode-only">

Later when validating image URLs, a relative URL is passed to the URL constructor, which results in an error being thrown.

vscode-vsce/src/package.ts

Lines 779 to 782 in 955c760

const src = decodeURI(rawSrc);
const srcUrl = new url.URL(src);

Fixes

The regex responsible for replacing links has been modified to support the # character.

I have also updated the test suite accordingly.

@joaomoreno joaomoreno enabled auto-merge (squash) July 15, 2022 08:13
@joaomoreno joaomoreno merged commit 7e16ed7 into microsoft:main Jul 15, 2022
@github-actions
Copy link

🎉 This PR is included in version 2.9.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@nhedger nhedger deleted the fix/issue-739 branch July 15, 2022 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vsce publish error "Invalid URL"
2 participants