WebGitNet icon indicating copy to clipboard operation
WebGitNet copied to clipboard

Powershell files served as binary

Open seankearon opened this issue 11 years ago • 3 comments

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.)

seankearon avatar May 15 '13 08:05 seankearon

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.

otac0n avatar May 15 '13 18:05 otac0n

That does the job - many thanks!

seankearon avatar May 16 '13 06:05 seankearon

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.

otac0n avatar May 26 '13 01:05 otac0n