Repeated segments should be supported by passing array to pathToRegExp.compile
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript
- Lĩnh vực
- backend
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- JavaScript
- Star
- 617
- Fork
- 120
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của vercel/serve-handler
-
FD leak on 304 Not Modified: opened read stream is never destroyed (leads to EMFILE)Có thể đã có người làm @jaideeppyne đã nhận 47 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
vercel/serve-handler#235 · 1 reaction ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
vercel/serve-handler#231 · 2 bình luận · 5 reaction ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
vercel/serve-handler#165 · 1 bình luận ·
-
Allow serving virtual filesĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
vercel/serve-handler#223 ·
-
Rewrite not working with external url with the portCó thể làm lại được @symtalha14 đã nhận 197 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
vercel/serve-handler#210 · 1 bình luận · 3 reaction ·
Tất cả issue của vercel/serve-handler
Issue tương tự
-
area: core complexity: easy impact: medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
ueberdosis/tiptap#8668 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
follow-redirects - CVE-2026-116689Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 70/100
axios/axios#11409 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add: Russia-24 +2Đang mởchannels:add check:passed
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 4 ngày
-
upstream-dfinity-icp-cli-recipes-static-site upstream-sync
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
dfinity/developer-docs#442 ·
Maintainer thường phản hồi trong vòng 2 ngày