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

Serve files with no extension #43

Merged
merged 2 commits into from
Nov 18, 2016
Merged

Serve files with no extension #43

merged 2 commits into from
Nov 18, 2016

Conversation

taravancil
Copy link
Contributor

Fixes #25

@TehShrike
Copy link

Sweeeet. I am very excited for this to get merged and deployed!

details.relative = path.join(subPath, details.base)

if (await isDir(filePath)) {
details.base += '/'
} else {
details.ext = details.ext.split('.')[1] || 'txt'

Choose a reason for hiding this comment

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

Why the || 'txt'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For files with no extension, details.ext.split('.')[1] is undefined. details.ext is used here to add a class that determines which icon is used, and if it's undefined, the class that renders the directory icon will apply.

Using anyrandomstring instead of txt would yield the same results, but I chose txt in order to be consistent with how.txt files are handled.

Choose a reason for hiding this comment

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

Ah, thanks for the explanation! I asked because it was confusing. 👍

@leo
Copy link
Contributor

leo commented Nov 18, 2016

Thanks a lot! 😊

@leo leo merged commit f4659bc into vercel:master Nov 18, 2016
@burtontanner
Copy link

burtontanner commented Jul 2, 2019

I still cannot serve files without extensions. Im using version 11.0.2. Any Ideas? Here is what run in the terminal. serve ./current/www/ --single -p 5000

@discordianfish
Copy link

Same, I feel like there might be a regression?

@discordianfish
Copy link

I think this broke it: vercel/serve-handler@2b5d6a0

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.

Returns 404 errors for files without extensions
6 participants