Skip to content

Relative paths are not transformed #10

@JounQin

Description

@JounQin
    @@ -25,71 +25,71 @@
        {
          "column": 1,
          "endColumn": 33,
          "endLine": 17,
          "line": 17,
    -     "message": "Cannot find file `../../getting-started/next`",
    +     "message": "Cannot find file `..\..\getting-started\next`",
          "nodeType": "Program",
          "ruleId": "remark-validate-links:missing-file-missing-file",
          "severity": 1,
        },

Activity

JounQin

JounQin commented on Mar 24, 2025

@JounQin
Author

I tried:

const { createSnapshotSerializer } = require('path-serializer')

const serializer = createSnapshotSerializer({
  features: {
    addDoubleQuotes: false,
    escapeDoubleQuotes: false,
  },
  replacePost: [
    {
      match: /(['"`])(\.\.([\\/]))+([\w-]+\3)+[^\\/]*\1/g,
      mark: sub => 'relative/' + sub.replaceAll('\\', '/'),
    },
  ],
})

module.exports = serializer

Well it works, with <RELATIVE_GETTING_STARTED_NEXT>, but actually I want ../../getting-started/next.

SoonIter

SoonIter commented on Apr 22, 2025

@SoonIter
Member

Hey, I add #13 for workaround to this feature

if you wanto serialize relative path by default in path-serializer pipeline, you can add test cases or pr to this repo, there may be some edge cases when using regular expressions for replacement.

linked a pull request that will close this issue on Apr 22, 2025
SoonIter

SoonIter commented on Apr 22, 2025

@SoonIter
Member

you can review #15

What is the source of this regular /(['"])(..([\/]))+([\w-]+\3)+[^\\/]*\1/g` expression, is it sufficiently solid?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @JounQin@SoonIter

      Issue actions

        Relative paths are not transformed · Issue #10 · rspack-contrib/path-serializer