Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Issue #48 #56

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/hyper-express/src/components/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,14 @@ class Server extends Router {
this.#routes[method][pattern] = route;

// Bind the uWS route handler which pipes all incoming uWS requests to the HyperExpress request lifecycle
return this.#uws_instance[method](pattern, (response, request) => {
const callback = (response, request) => {
this._handle_uws_request(route, request, response, null);
});
};
this.#uws_instance[method](pattern, callback);

// Shall the registered (/foo) route also handle (/foo/) requests?
this.#uws_instance[method](pattern + '/', callback);
return;
}
}

Expand Down
3 changes: 3 additions & 0 deletions packages/hyper-express/src/components/router/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ class Router {
// This is because uWebsockets.js does not treat non-leading slashes as catchall stars
if (pattern.startsWith('*')) pattern = '/' + pattern;

// Handle trailing slash for all patterns except the root pattern(/).
if (pattern !== '/' && pattern.endsWith('/')) pattern = pattern.slice(0, -1);

// Parse the middlewares into a new array to prevent mutating the original
const middlewares = [];

Expand Down