Repeated segments should be supported by passing array to pathToRegExp.compile
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- javascript
- 領域
- backend
調査の方向性
Start at toTarget in src/index.js around lines 79-86 and compare the path-to-regexp compile documentation with how repeated parameters are assigned. Add coverage for repeated segments in rewrites and redirects, then update the documentation with the required destination pattern and verify the affected tests pass.
索引モデルが issue の本文から書いたものです。
説明
Context
- Serving react app under
/appprefix e.g.example.com/app/products - Installed
serveand customized withserve.json - Used
"homepage":"/app"inpackage.jsonaccording to CRA docs - Asset path is correctly inferred and generated but
serveis not serving asset files correctly underbuild/static/...
serve.json used for above:
{
"public": "build",
"rewrites": [
{ "source": "/app/static/:segment*", "destination": "/static/:segment*" },
{ "source": "/app", "destination": "/index.html"}.
{ "source": "/app/**", "destination": "/index.html"}
]
}
After some debugging, I identified the issue to be in toTarget. We are not passing in array of parameters when we are compiling the valid path https://github.com/zeit/serve-handler/blob/e7c4e42a63e9cd59b43256bb4ca04a22a5f77994/src/index.js#L79-L86
We should be passing array according to the docs(v2.2.1 that we are using). If not it treats the whole string as a single segment value and encodes / .
Debug logs:
// applyRewrites
relativePath: "/app/static/css/2.c7bb94bc.chunk.css" //argument
rewrittenPath: "/app/%2Fcss%2F2.c7bb94bc.chunk.css" // return value
// toTarget
props: {
"segment": "/css/2.c7bb94bc.chunk.css"
}
normalizedDest: "/static/:segment*"
toPath(props): "/static/%2Fcss%2F2.c7bb94bc.chunk.css"
This should be easily fixed by doing a split by / when we are setting the props i.e. props[name] = results[index + 1].split("/");
This will fix repeated segment for redirects as well.
Documents should also be updated with instructions on how to use repeated segment. (I figured out during debugging that destination needs * as well else the compile function will complain that the url built does not match the destination pattern 😅)
Not sure if my proposed solution is correct but it works locally for me so far. I am happy to work on this with tests and docs for repeated segment
- 主要言語
- JavaScript
- スター
- 617
- フォーク
- 119
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
vercel/serve-handler のほかの issue
-
FD leak on 304 Not Modified: opened read stream is never destroyed (leads to EMFILE)対応中かも @jaideeppyne が 43 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
vercel/serve-handler#235 · リアクション 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
vercel/serve-handler#231 · コメント 2 件 · リアクション 5 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
vercel/serve-handler#165 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
vercel/serve-handler#223 ·
-
Rewrite not working with external url with the port再び着手できるかも @symtalha14 が 194 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
vercel/serve-handler#210 · コメント 1 件 · リアクション 3 件 ·
vercel/serve-handler の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
wazuh/wazuh-documentation#10584 ·
メンテナーはふだん 1 日以内に返信
-
documentation good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 94/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
InukaAsith/TwinDesk#84 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Graphify-Labs/graphify#4860 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
CommandCodeAI/command-code#1088 ·
メンテナーはふだん 2 日以内に返信