Skip to content

Commit 03420aa

Browse files
committed
override GistVirtualFile Extension to exclude base64 modifier
1 parent a3d0f91 commit 03420aa

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/ServiceStack.Common/IO/GistVirtualFiles.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ protected override void Initialize() { }
5252

5353
public static bool IsDirSep(char c) => c == '\\' || c == '/';
5454

55+
public const string Base64Modifier = "|base64";
56+
5557
public static bool GetGistContents(string filePath, Gist gist, out string text, out MemoryStream stream)
5658
{
57-
var base64FilePath = filePath + "|base64";
59+
var base64FilePath = filePath + Base64Modifier;
5860
foreach (var entry in gist.Files)
5961
{
6062
var file = entry.Value;
@@ -214,7 +216,7 @@ public void WriteFile(string virtualPath, string contents)
214216
public void WriteFile(string virtualPath, Stream stream)
215217
{
216218
var base64 = ToBase64(stream);
217-
var filePath = SanitizePath(virtualPath) + "|base64";
219+
var filePath = SanitizePath(virtualPath) + Base64Modifier;
218220
Gateway.WriteGistFile(GistId, filePath, base64);
219221
ClearGist();
220222
}
@@ -248,7 +250,7 @@ public void AppendFile(string filePath, Stream stream)
248250
public string ResolveGistFileName(string filePath)
249251
{
250252
var gist = GetGist();
251-
var baseFilePath = filePath + "|base64";
253+
var baseFilePath = filePath + Base64Modifier;
252254
foreach (var entry in gist.Files)
253255
{
254256
if (entry.Key == filePath || entry.Key == baseFilePath)
@@ -379,6 +381,8 @@ public class GistVirtualFile : AbstractVirtualFileBase
379381

380382
public string GistId => PathProvider.GistId;
381383

384+
public override string Extension => Name.LastRightPart('.').LeftPart('|');
385+
382386
public GistVirtualFile(GistVirtualFiles pathProvider, IVirtualDirectory directory)
383387
: base(pathProvider, directory)
384388
{

src/ServiceStack.Common/VirtualPath/AbstractVirtualFileBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public abstract class AbstractVirtualFileBase : IVirtualFile
1616

1717
public IVirtualPathProvider VirtualPathProvider { get; set; }
1818

19-
public string Extension => Name.LastRightPart('.');
19+
public virtual string Extension => Name.LastRightPart('.');
2020

2121
public IVirtualDirectory Directory { get; set; }
2222

0 commit comments

Comments
 (0)