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

1.4 Broke rewrites #4261

Closed
jasonkuhrt opened this issue Oct 9, 2024 · 8 comments
Closed

1.4 Broke rewrites #4261

jasonkuhrt opened this issue Oct 9, 2024 · 8 comments
Labels
upstream Related to the dependencies

Comments

@jasonkuhrt
Copy link

Describe the bug

I use these rewrites in my Vitepress config:

rewrites: {
    ':section/{:_(\\d+_)}?:one/{:_(\\d+_)}?:two/{:_(\\d+_)}?:three'   : ':section/:one/:two/:three',
    ':section/{:_(\\d+_)}?:one/{:_(\\d+_)}?:two'                      : ':section/:one/:two',
    ':section/{:_(\\d+_)}?:one'                                       : ':section/:one'
  },

Reproduction

I have a failing case right now on this PR, example build failure: https://github.com/jasonkuhrt/graffle/actions/runs/11219992004/job/31187185529?pr=1168.

CleanShot 2024-10-09 at 10 23 25@2x

Expected behavior

I expected that a minor release of Vitepress would not break the config.

System Info

System:
    OS: macOS 15.0
    CPU: (8) arm64 Apple M1 Pro
    Memory: 78.25 MB / 32.00 GB
    Shell: 3.5.0 - /opt/homebrew/bin/fish
  Binaries:
    Node: 22.7.0 - ~/Library/pnpm/node
    npm: 10.8.2 - ~/Library/pnpm/npm
    pnpm: 9.12.1 - /opt/homebrew/bin/pnpm
  Browsers:
    Brave Browser: 114.1.52.122
    Chrome: 129.0.6668.91
    Safari: 18.0
  npmPackages:
    vitepress: ^1.3.4 => 1.3.4 


### Additional context

_No response_

### Validations

- [X] Check if you're on the [latest VitePress version](https://github.com/vuejs/vitepress/releases/latest).
- [X] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)
- [X] Read the [docs](https://vitepress.dev).
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@jasonkuhrt jasonkuhrt added the bug: pending triage Maybe a bug, waiting for confirmation label Oct 9, 2024
@brc-dd
Copy link
Member

brc-dd commented Oct 9, 2024

path-to-regexp had a vulnerability. Their fix broke your rewrite patterns somehow - pillarjs/path-to-regexp#324

This likely won't be fixed at source as it's a vulnerability patch not exactly a regression. You can use pnpm.overrides to lock it to ~6.2 (not recommended in long term). Or update your pattern to work with newer versions.

@brc-dd brc-dd added upstream Related to the dependencies and removed bug: pending triage Maybe a bug, waiting for confirmation labels Oct 9, 2024
@yshrsmz
Copy link

yshrsmz commented Oct 9, 2024

I had a similar problem.

I had this rewrites config

rewrites: {
 'posts/:skipped/:year-:month-:day-:slug.md': ':year/:month/:day/:slug/index.md',
}

and now /posts/2018/2018-03-27-settingup-github-slack.md becomes /2018-03-27/settingup/github/slack/index.html.

It was once rewrited as /2018/03/27/settingup-github-slack/index.html.

Edit: changing the pattern to posts/:skipped/:year-:month-:day-:slug(.*).md fixed the issue for me.

@jasonkuhrt
Copy link
Author

I'm not sure this library is the best match for Vitepress. The security issue in question is not relevant for a static site generator is it?

May I ask that you add the option for a function to be passed to rewrite paths? I've already struggled to use the existing approach and not sure how to fix it now. The version Vitepress uses is not the latest, its docs are not what's currently on the latest readme but rather I have to find older commits. All of this for me is just extra work versus having a function I could just implement what I want.

Would that be doable or does the currently declarative approach have deeply dependent internals?

@brc-dd
Copy link
Member

brc-dd commented Oct 12, 2024

Yeah we can support passing a function 👀

@brc-dd
Copy link
Member

brc-dd commented Oct 12, 2024

Will be out in next version.

@jasonkuhrt
Copy link
Author

@brc-dd thanks that's great to hear! Looking forward to it.

@brc-dd
Copy link
Member

brc-dd commented Oct 13, 2024

Released. Should I close this issue? I don't think we can do much about path-to-regexp breaking edge cases from vitepress' side. And I also updated the docs to link to it's v6 version. We won't update it to v8 till our next major 👀

@jasonkuhrt
Copy link
Author

Yep sounds good let's close!

@brc-dd brc-dd closed this as completed Oct 14, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
upstream Related to the dependencies
Projects
None yet
Development

No branches or pull requests

3 participants