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

Add pretty urls #1193

Merged
merged 2 commits into from
Aug 7, 2023
Merged

Add pretty urls #1193

merged 2 commits into from
Aug 7, 2023

Conversation

nlopes
Copy link
Contributor

@nlopes nlopes commented Aug 6, 2023

This adds a new flag namely --pretty-urls that when enabled will serve the equivalent .html if it exists.

Very much the same approach that netlify
uses
.

It can be quite useful when having hrefs like /about serve /about.html.

@nlopes
Copy link
Contributor Author

nlopes commented Aug 6, 2023

Hi 👋

I don't believe this was a feature ever requested or in the issue tracker (that I was able to find) but it's one that I use myself.
Happy to keep this as a branch on my own but I thought it would be a nice little feature for miniserve.

Feel free to completely discard if you don't think it is something you want to support.

This adds a new flag namely `--pretty-urls` that when enabled will serve the equivalent
`.html` if it exists.

Very much the same approach that [`netlify`
uses](https://docs.netlify.com/site-deploys/post-processing/).

It can be quite useful when having hrefs like `/about` serve `/about.html`.
Copy link
Owner

@svenstaro svenstaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a cool feature! Good code too, just small nits.

src/main.rs Outdated Show resolved Hide resolved
src/main.rs Show resolved Hide resolved
- remove info logging
- add comment to clarify logic
@nlopes nlopes requested a review from svenstaro August 7, 2023 11:06
@svenstaro
Copy link
Owner

Good work!

@svenstaro svenstaro merged commit e3c0abb into svenstaro:master Aug 7, 2023
20 checks passed
svenstaro added a commit that referenced this pull request Aug 7, 2023
@nlopes nlopes deleted the nlopes-pretty-urls branch August 7, 2023 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants