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: strip query string before checking md extension #12712

Merged
merged 1 commit into from
Dec 11, 2024
Merged

Conversation

ascorbic
Copy link
Contributor

Changes

Currently the markdown vite plugin just checks if the id ends in a makrdown extension. This breaks if the id includes a query param. This PR strips the query string before checking.

Fixes #12711

Testing

Added test

Docs

Copy link

changeset-bot bot commented Dec 11, 2024

🦋 Changeset detected

Latest commit: 38120e5

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Dec 11, 2024
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@@ -18,9 +18,11 @@ export function isURL(value: unknown): value is URL {
}
/** Check if a file is a markdown file based on its extension */
export function isMarkdownFile(fileId: string, option?: { suffix?: string }): boolean {
// Strip query string
const id = fileId.split("?")[0];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have a stripQueryParams util somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find one. There's getFileInfo which does return an id with the params stripped - and which the markdown plugin calls immediately after, but it does lots of other stuff which is probably overkill for something that will be called on every module. Better to have something extra simple when it's in the kinda-hot path.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do! :) removeQueryString

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh!

Copy link

codspeed-hq bot commented Dec 11, 2024

CodSpeed Performance Report

Merging #12712 will not alter performance

Comparing md-extension (38120e5) with main (2aaed2d)

Summary

✅ 4 untouched benchmarks

@ascorbic ascorbic merged commit b01c74a into main Dec 11, 2024
16 checks passed
@ascorbic ascorbic deleted the md-extension branch December 11, 2024 10:21
@astrobot-houston astrobot-houston mentioned this pull request Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Search parameters with an .md extension break astro
3 participants