Comments (2)
im closing this as it's not something I expect us to seriously prioritize
from discussions.
for reference it was this issue, and the dev had a good outcome from my human written but LLM assisted debugging: pillarjs/routington#29
the output the LLM gave me with just their issue (which was a pretty dang good issue, it included enough code to know exactly what they were doing):
The issue you're encountering with matching a query string (/name?age=50) using routington is because routington is designed to match URL paths, not query strings. The query string is not considered part of the URL path; it's a separate component used to pass additional data to the server. Therefore, when you try to match /name?age=50, it won't work as expected because routington is looking for a path that matches exactly, without considering the query string.
To fix this issue, you need to separate the path from the query string before matching. You can use the URL or another method to parse the incoming request URL, extract the path without the query string, and then pass it to your match function. Here's how you could adjust the dispatcher function to handle this:
function dispatcher(request: { path: string; method: string }): { param: string; handler: Function } | string | never { // Extract path without query string const url = new URL(request.path, `http://${request.headers?.host || 'localhost'}`); const pathWithoutQueryString = url.pathname; const match = router.match(pathWithoutQueryString); if (!match) { console.log('404 - Not Found'); return "" }; const node = match.node; const cb = node[request.method]; if (!cb) { console.log('405 - Method Not Allowed'); return ""; } return { param: match.param, handler: cb // You might need to check if cb is not undefined before calling it } }This adjustment uses the URL object to parse the incoming request.path, extracting the pathname (which excludes the query string) before it's passed to router.match. Note that this example assumes request.path includes the full URL; you might need to adjust this based on how your actual request object is structured. If request.path already contains only the path, you won't need to prepend a base URL.
Also, ensure you handle cases where the method does not exist on the matched route to avoid runtime errors.
from discussions.
Related Issues (20)
- Module Format HOT 15
- Types? HOT 3
- How can I update the session with data from the database HOT 1
- Pilot LFX Insights On The Express Project HOT 15
- 2024-03-04 Express TC Meeting
- 2024-03-04 Express TC Meeting HOT 12
- 2024-03-04 Express TC Meeting
- How does the Express LTS strategy apply to modules not shipped directly with `express`? HOT 9
- EFI: Express documentation (expressjs.com website)
- Wayward Packages not under Express umbrella orgs HOT 5
- Workflow to auto close and lock PRs that match the `Update Readme.md` pattern HOT 2
- 2024-03-13 Express TC Meeting HOT 11
- 2024-03-18 Express TC Meeting HOT 7
- 2024-03-20 Express TC Meeting HOT 2
- 2024-03-20 Express TC Meeting HOT 1
- 2024-04-01 Express TC Meeting HOT 5
- Why are s: and hmac necessary in the express session cookie? HOT 2
- 2024-03-27 Express TC Meeting
- 2024-03-27 Express Working Session HOT 2
- 2024-03-27 Express TC Meeting
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from discussions.