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

Fix #8: Rollup of changes #9

Merged
merged 1 commit into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,16 @@ public CompositeFileDefinition WritePathToStream(ClientDependencyType type, stri
CompositeFileDefinition def = null;
if (!string.IsNullOrEmpty(path))
{
//all config based extensions and all extensions registered by file writers
var fileBasedExtensions = ClientDependencySettings.Instance.FileBasedDependencyExtensionList
.Union(FileWriters.GetRegisteredExtensions())
.ToList();

try
{
//var fi = new FileInfo(context.Server.MapPath(path));

var extension = Path.GetExtension(path);

//all config based extensions and all extensions registered by file writers
var fileBasedExtensions = ClientDependencySettings.Instance.FileBasedDependencyExtensionList
.Union(FileWriters.GetRegisteredExtensions());

if (fileBasedExtensions.Contains(extension.ToUpper()))
{
IVirtualFileWriter virtualWriter;
Expand Down Expand Up @@ -188,16 +188,20 @@ public CompositeFileDefinition WritePathToStream(ClientDependencyType type, stri
if (Uri.TryCreate(path, UriKind.RelativeOrAbsolute, out uri) && uri.IsLocalUri(context))
{
var localPath = uri.PathAndQuery;
var fi = new FileInfo(context.Server.MapPath(localPath));
if (fi.Exists)
var extension = Path.GetExtension(localPath);
if (fileBasedExtensions.Contains(extension.ToUpper()))
{
try
{
WriteFileToStream(sw, fi, type, path, context); //internal request
}
catch (Exception ex1)
var fi = new FileInfo(context.Server.MapPath(localPath));
if (fi.Exists)
{
ClientDependencySettings.Instance.Logger.Error($"Could not load file contents from {path}. EXCEPTION: {ex1.Message}", ex1);
try
{
WriteFileToStream(sw, fi, type, path, context); //internal request
}
catch (Exception ex1)
{
ClientDependencySettings.Instance.Logger.Error($"Could not load file contents from {path}. EXCEPTION: {ex1.Message}", ex1);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ClientDependency.Core/IClientDependencyFileExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static string ResolveFilePath(this IClientDependencyFile file, HttpContex
}

var uri = new Uri(new Uri("https://example.com"), filePath);
return uri.PathAndQuery;
return HttpUtility.UrlDecode(uri.PathAndQuery);
}
}
}