Questions tagged [path-to-regexp]

13 questions
3
votes
0 answers

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 to achieve something like this, //…
2
votes
2 answers

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: 'SomePage', component: () =>…
1
vote
0 answers

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 string directly (i.e. the very same string that is…
zkwsk
  • 1,960
  • 4
  • 26
  • 34
1
vote
1 answer

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 , but it didn't work when the wildcard matches two or more…
jddxf
  • 1,850
  • 3
  • 12
  • 19
1
vote
1 answer

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 express compiles it to some ridiculous…
Doc999tor
  • 190
  • 3
  • 15
1
vote
1 answer

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/items/1 I would assume the two paths would…
0
votes
1 answer

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://swup.js.org/plugins/route-name-plugin None of the…
HandiworkNYC.com
  • 10,914
  • 25
  • 92
  • 154
0
votes
2 answers

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 expectation is that this.$route.params.length will…
0
votes
0 answers

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-to turn them back to paths?
Omar Dulaimi
  • 846
  • 10
  • 30
0
votes
1 answer

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/express-route-tester/) : Express Route Tester It works…
LeDev
  • 1
  • 2
0
votes
1 answer

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 directs to the component just fine but doesn't store…
Tremendus Apps
  • 1,497
  • 12
  • 20
0
votes
1 answer

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 like this doesnt work…
user3410823
  • 65
  • 1
  • 1
  • 7
0
votes
1 answer

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 without success. I have been using…
Patrick
  • 29
  • 1
  • 6