diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2022-05-03 22:46:39 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2022-05-03 22:46:39 -0500 |
| commit | cd2a45dcc097d1a5a3ec299a644a630acd63158d (patch) | |
| tree | 85318b6dc68300a1aeeaf7797c876b6186b1d44d /src/slskd/Program.cs | |
| parent | e52d636f8a2069394653992384ef7f3cdcafea5d (diff) | |
| download | slskd-cd2a45dcc097d1a5a3ec299a644a630acd63158d.tar.gz | |
stub file rewriting
Diffstat (limited to 'src/slskd/Program.cs')
| -rw-r--r-- | src/slskd/Program.cs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 5ce6bfd4..7510f59a 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -633,6 +633,8 @@ namespace slskd } else { + RewriteStaticContentUrls(contentPath, urlBase); + fileServerOptions = new FileServerOptions { FileProvider = new PhysicalFileProvider(contentPath), @@ -831,6 +833,54 @@ namespace slskd } } + private static void RewriteStaticContentUrls(string contentPath, string urlBase) + { + if (string.IsNullOrEmpty(urlBase) || urlBase == "/") + { + // nothing to rewrite + return; + } + + // Log.Warning("Rewriting URLs in static content to reflect custom base url {UrlBase}", urlBase); + // Log.Warning("This is a one-time operation"); + + // var rewrittenFiles = 0; + // var files = System.IO.Directory.GetFiles(contentPath, "*", SearchOption.AllDirectories); + + // foreach (var file in files) + // { + // bool rewritten = false; + // var contents = System.IO.File.ReadAllText(file); + + // if (contents.Contains("../../static") || contents.Contains("./static")) + // { + // contents = contents.Replace("../../static", $"{urlBase}/static"); + // contents = contents.Replace("./static", $"{urlBase}/static"); + // System.IO.File.WriteAllText(file, contents); + // Log.Warning("Rewrote paths in {File}", Path.GetFileName(file)); + // rewritten = true; + // } + + // if (contents.Contains("window.urlBase=\"/\"")) + // { + // contents = contents.Replace("window.urlBase=\"/\"", $"window.urlBase=\"{urlBase}\""); + // System.IO.File.WriteAllText(file, contents); + // Log.Warning("Rewrote urlBase in {File}", Path.GetFileName(file)); + // rewritten = true; + // } + + // if (rewritten) + // { + // rewrittenFiles++; + // } + // } + + // if (rewrittenFiles == 0) + // { + // Log.Warning("No files were rewritten."); + // } + } + private static void GenerateX509Certificate(string password, string filename) { Log.Information("Generating X509 certificate..."); |
