WebGitNet
WebGitNet copied to clipboard
Powershell files served as binary
Powershell scripts are served up as application/octet-stream
. Is there a way to serve these up as text? (I've already tried adding a MIME type in IIS.)
The current implementation first checks a file, called "mime-types.txt", located in the sharedlib project.
If it fails to find the file extension in that file, it searches the windows registry for the mime type.
See: https://github.com/otac0n/WebGitNet/blob/master/WebGitNet.SharedLib/MimeUtilities.cs
You can add a value HKEY_CLASSES_ROOT\.ps1\ContentType
set to something like text/x-powershell-source
on your server, or you can modify that mime-types.txt file.
I'm going to keep this bug open until we have an entry in mime-types.txt for powershell.
That does the job - many thanks!
There are several examples of this issue:
.cmd, .nsi, .ls, .bxrc
The point is that it is an insurmountable challenge to build an exhaustive list. We should default to the git method of detecting a binary vs text file. Specifically, we should check the first chunk (1kb?) of the file for any null bytes. This is slightly problematic when dealing with multibyte encodings.