-
Notifications
You must be signed in to change notification settings - Fork 41
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
wp-now: add wp-admin redirection with trailing slash #60
wp-now: add wp-admin redirection with trailing slash #60
Conversation
packages/wp-now/src/start-server.ts
Outdated
@@ -33,6 +33,16 @@ const requestBodyToString = async (req) => | |||
}); | |||
}); | |||
|
|||
function addTrailingSlash(path) { | |||
return (req, res, next) => { | |||
if (req.url === path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will that work if the URL is /wp-admin?a=b
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested and it does not.
Maybe addTrailingSlash
should be a standalone function with tests, and then we should have some other function for this middleware.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Now it supports get parameters
/wp-admin?a=b
- I moved the function to a new file, and included tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work well! Thanks for adding tests 😊
Document the public and private APIs of all the packages in this repository. This commit is polluted with code refactoring since many ideas stood out as overly complex while writing the docs. There isn't much value in separating them out at this point so they're here. Follow-up work: * Iterate on the docs, fix typos, gather more feedback, reword confusing fragments. * Generate a proper reference doc in a markdown format. It should include the top-level module documentation, function documentation, and the classes + their methods. I'm not sure which tool can handle that correctly. * Add the missing `wordpress-wasm` module documentation * Fill-in any remaining blanks
This PR populates /docs with a step-by-step documentation connecting the priors documentation efforts shipped in: * API Reference documentation WordPress#63 * Migrate the project to TypeScript WordPress#61 * Add developer documentation WordPress#60 * Monorepo WordPress#57
What?
It adds a redirection to
/wp-admin
to add the trailing slash/wp-admin/
so core loads the correct links in the sidebar.Why?
How?
I created a middleware to add trailing slash given a path.
Testing Instructions
npx nx build wp-now
node dist/packages/wp-now/main.js start
http://127.0.0.1:8881/wp-admin
(without the last slash)http://127.0.0.1:8881/wp-admin/
and the sidebar menu has the correct links.