Get wildcard value
See original GitHub issueFirstly, lovely little router this but one thing I’m not clear on. Is there a way in the handler, to get the value that a wildcard matched on. For example,
const router = Router()
router.get('/maps/tiles/vector/*', vectorTilesHandler)
router.get('/maps/tiles/static/*', staticTilesHandler)
router.get('/maps/packs/vector/*', vectorPacksHandler)
router.get('/maps/packs/static/*', staticPacksHandler)
I’d like to get the whole wildcard value in the handler. I can get the full url, but then that means I need to remove the host and duplicate the initial piece of path so I can strip that off the string.
Likewise I can’t use parameters because you can’t have a greedy parameter that takes all segments. The reason I need the wildcard is so i can proxy it as is (in these cases).
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (8 by maintainers)
Top Results From Across the Web
Get only wild card value using regular expression
This should do it : (DEMO) string input = "Book_1234_ABC"; MatchCollection matches = Regex.Matches(input, @"_([A-Za-z0-9]*)"); foreach ...
Read more >Examples of wildcard characters - Microsoft Support
Wildcards are special characters that can stand in for unknown characters in a text value and are handy for locating multiple items with...
Read more >Wildcard Function (GNU make)
$(wildcard pattern …) This string, used anywhere in a makefile, is replaced by a space-separated list of names of existing files that match...
Read more >Excel Wildcard Characters - Why Aren't You Using These?
You can use the asterisk (*) wildcard character in data filter to get a list ... Partial look-up is needed when you have...
Read more >SQL Wildcard Characters - W3Schools
CustomerID CustomerName ContactName Address
1 Alfreds Futterkiste Maria Anders Obere Str. 57
2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constitución...
3 Antonio...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kwhitley Here’s an example of how Express (JS) and Sinatra (Ruby) handle unnamed wildcards:
From the docs, they state Express (v4) takes the approach of making these index based on
params
. For example, for the path/file/*
, express exposes the splat parameter atreq.params[0]
(express req.params)Alternatively, the Ruby library mustermann used by sinatra uses the default name “splat”, so you can get the wildcard capture group at
params["splat"]
.Hope that’s useful!
Thanks for understanding! When I get some free time this week, I’ll try to take a stab at a splat enabled wrapper! 😃