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

Loader does not decode pathPrefix correctly #30533

Closed
herecydev opened this issue Mar 29, 2021 · 0 comments · Fixed by #30682
Closed

Loader does not decode pathPrefix correctly #30533

herecydev opened this issue Mar 29, 2021 · 0 comments · Fixed by #30682
Labels
topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) type: bug An issue or pull request relating to a bug in Gatsby

Comments

@herecydev
Copy link
Contributor

Description

Supplying an unencoded pathPrefix, such as /امتحان fails validation with an error message: "pathPrefix" must be a valid relative uri.

So one can supply something like pathPrefix: "/" + encodeURI("امتحان"), which solves that problem but then the app is not functional:

Screenshot 2021-03-29 141748

The issue looks to stem from these lines of code: https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/cache-dir/find-path.js#L9-L11

The matching decodes the pathname uri, but because the path_prefix is not decoded it will fail to match.

Steps to reproduce

  1. Clone https://github.com/herecydev/encoding-path-prefix-bug
  2. Run yarn build
  3. Run yarn serve
  4. Navigate to http://localhost:9000/%D8%A7%D9%85%D8%AA%D8%AD%D8%A7%D9%86/

Expected result

Either the config should allow an unencoded pathPrefix or loader can correctly encode/decode when it needs to

Actual result

Gatsby loader fails to decode the pathPrefix

Environment

  System:
    OS: Windows 10 10.0.19043
    CPU: (32) x64 AMD Ryzen 9 5950X 16-Core Processor            
  Binaries:
    Node: 14.15.4 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.14.10 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.906.0), Chromium (89.0.774.63)
  npmPackages:
    gatsby: ^3.1.2 => 3.1.2 
    gatsby-plugin-gatsby-cloud: ^2.1.0 => 2.1.0 
    gatsby-plugin-image: ^1.1.2 => 1.1.2 
    gatsby-plugin-manifest: ^3.1.0 => 3.1.0 
    gatsby-plugin-offline: ^4.1.0 => 4.1.0 
    gatsby-plugin-react-helmet: ^4.1.0 => 4.1.0 
    gatsby-plugin-sharp: ^3.1.2 => 3.1.2 
    gatsby-source-filesystem: ^3.1.0 => 3.1.0 
    gatsby-transformer-sharp: ^3.1.0 => 3.1.0 
@herecydev herecydev added the type: bug An issue or pull request relating to a bug in Gatsby label Mar 29, 2021
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Mar 29, 2021
@herecydev herecydev changed the title Unencoded pathPrefix fails validation Loader does not decode pathPrefix correctly Mar 29, 2021
@LekoArts LekoArts added topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants