Repeated segments should be supported by passing array to pathToRegExp.compile
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript
- Área
- backend
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- JavaScript
- Estrellas
- 617
- Forks
- 119
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de vercel/serve-handler
-
FD leak on 304 Not Modified: opened read stream is never destroyed (leads to EMFILE)Posiblemente ocupada @jaideeppyne la tomó hace 43 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
vercel/serve-handler#235 · 1 reacción ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
vercel/serve-handler#231 · 2 comentarios · 5 reacciones ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
vercel/serve-handler#165 · 1 comentario ·
-
Allow serving virtual filesAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
vercel/serve-handler#223 ·
-
Rewrite not working with external url with the portQuizá libre de nuevo @symtalha14 la tomó hace 194 días y no hay ningún pull request abierto. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
vercel/serve-handler#210 · 1 comentario · 3 reacciones ·
Todos los issues de vercel/serve-handler
Issues similares
-
bug documentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
awslabs/visual-asset-management-system#880 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
[BUG]: Workspace settings forms stay at 50% width on narrow screens and wrap text word by wordAbiertopossible bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Mintplex-Labs/anything-llm#6889 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
swc-project/swc-next#1165 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
nhsuk/nhsuk-prototype-kit-package#439 ·
Los mantenedores suelen responder en 1 día