mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
Ensure we always update the index page with the new base url
This commit is contained in:
parent
80a3dedf87
commit
472803ec31
1 changed files with 10 additions and 3 deletions
|
@ -268,10 +268,17 @@ namespace Ombi
|
|||
throw new Exception(error);
|
||||
}
|
||||
var indexHtml = await File.ReadAllTextAsync(indexPath);
|
||||
indexHtml = indexHtml.Replace("<script type='text/javascript'>window[\"baseHref\"] = '/';</script>"
|
||||
, $"<script type='text/javascript'>window[\"baseHref\"] = '{trimmedBaseUrl}';</script><base href=\"{baseUrl}\">", StringComparison.InvariantCultureIgnoreCase);
|
||||
var sb = new StringBuilder(indexHtml);
|
||||
|
||||
await File.WriteAllTextAsync(indexPath, indexHtml);
|
||||
var headPosition = indexHtml.IndexOf("<head>");
|
||||
var firstLinkPosition = indexHtml.IndexOf("<link");
|
||||
|
||||
sb.Remove(headPosition + 6, firstLinkPosition - headPosition - 6);
|
||||
|
||||
sb.Insert(headPosition + 6,
|
||||
$"<script type='text/javascript'>window[\"baseHref\"] = '{trimmedBaseUrl}';</script><base href=\"{trimmedBaseUrl}/\">");
|
||||
|
||||
await File.WriteAllTextAsync(indexPath, sb.ToString());
|
||||
|
||||
Console.WriteLine($"Wrote new baseurl at {indexPath}");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue