16 questions
0
votes
1
answer
222
views
Express 5 optional route parameters (:param?) throw PathError with path-to-regexp
I'm using Express 5.1.0 with Node.js v22.19.0, and I want to define a route where the parameter is optional, like /directory or /directory/someFolder.
Here's the code I tried:
import express from '...
3
votes
2
answers
3k
views
How to solve path-to-regexp dependency issue in Express 5.1.0?
I created this simple file:
import express from "express";
import type { Request, Response } from "express";
const app = express();
const port = 3000;
app.get('/', (req:Request, ...
-2
votes
1
answer
58
views
The "^" character does not interpreted as a start of line in regular expression provided to the route handler
I have one issue with express I want to use "^" as we use it in Javascript regex but unfortunately it does not work...
so here i added "^" to give pattern to the storeName path ...
0
votes
1
answer
285
views
Wordpress + Swup JS / Route plugin + path to regex
My URL structure is as follows:
http://localhost:8888/cdw/work/foo-bar/
http://localhost:8888/cdw/work/bar-foo/
http://localhost:8888/cdw/work/etc-etc/
I'm using swup JS and the route plugin https://...
0
votes
2
answers
680
views
Vue-router - How to add custom suffix to route param?
I have this route path
/custom/:length(\\d+-letter-)?words
It matches below routes as expected ✅
/custom/3-letter-words
/custom/words
However, this.$route.params.length returns 3-letter-.
My ...
0
votes
0
answers
65
views
Is it possible to convert a regex back to its original/approximate path?
I have these regex expressions:
/^\/users\/?(?=\/|$)/i
/^\/?$/i
Which were generated using a library called Path-to-RegExp
The original paths were:
/users
/
So is there any way-however imperfect-...
1
vote
0
answers
553
views
path-to-regexp not matching when passing arguments as variables
I've run into a odd problem. When I try to test if path-to-regexp will match a given path I will not get a result when expected, if I pass the input string from a variable. But if I hard-code the ...
1
vote
1
answer
160
views
How to redirect all the route paths starting with foo to paths starting with bar
The examples below demonstrate what I want to achieve:
/foo => /bar
/foo/a => /bar/a
/foo/a/b => /bar/a/b
/foo/a/b/c => /bar/a/b/c
...
I've tried <Redirect from="/foo/(.*)" ...
0
votes
1
answer
303
views
A regex works fine with Express Route Tester but it failed when it used with NodeJS
I used express in a NodeJs project, and i want to be able to request my server with theses routes :
/dogs
/pinguin
/bear
/wolf
/cat
/rat
I use a regex for this (http://forbeslindesay.github.io/...
3
votes
2
answers
2k
views
Problem related to vue-router, i can not exclude some words from path regex
I have problem related to vue-router I need to exclude some group of words like: word1, some-word2, word3... from the router path
{
path: '/:pageIdenfifier(?!word1|some-word2|word3),
name: '...
1
vote
1
answer
95
views
Express route parsing with regex characters sets
Path: /1,2,3,456,678 - only numbers and commas, not anything else
Should be matched with regex-like path like this: /ids:(\\d+[,\\d]*) natively
But https://www.npmjs.com/package/path-to-regexp in ...
4
votes
0
answers
1k
views
How to define dynamic route path using regex in Nuxt's serverMiddleware?
I'm trying to define a regex based dynamic path in Nuxt's serverMiddleware, but I'm not able to figure out how to achieve it because in the doc also there is no any mention about dynamic route.
I want ...
0
votes
1
answer
1k
views
Can vue-router use regex route matching and pass the match as a named parameter
Under the hood, I understand the vue-router uses path-to-regexp to handle route matching.
If I use the route format:
/app/:collection(/^cases$?)/:id
This matches the route /app/cases/abc123 and ...
0
votes
1
answer
434
views
How to add float validation to Vue Routers paths?
For some reason I can't get a float to work in vue router paths.
/category/:category(\d+)/:post([-+]?([0-9]*\.[0-9]+|[0-9]+))
I've got numbers to work with :category(\d+)
But for some reason a regex ...
0
votes
1
answer
621
views
How to match an optional segment in vue-router with path-to-regexp
Vue-Router uses https://github.com/pillarjs/path-to-regexp to convert paths to regular expressions.
I have been trying to create an expression that matches an optional segment within an path but ...
1
vote
1
answer
870
views
How to render nested routes with multiple optional params and path placeholders?
I've been trying to use react-router to define a series of nested components/routes w/ optional params, but also separated by path placeholders.
i.e.
/list
/list/1
/list/items
/list/1/items
/list/1/...