mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 21:03:17 -07:00
fix: 🐛 Really really fix it this time?
This commit is contained in:
parent
3d3e8c99f1
commit
543d36e561
1 changed files with 6 additions and 6 deletions
|
@ -20,6 +20,7 @@ using Microsoft.Extensions.Logging.Abstractions;
|
|||
using Microsoft.Extensions.Logging;
|
||||
using Ombi.Api.TheMovieDb.Models;
|
||||
using System.Net.Http;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Ombi
|
||||
{
|
||||
|
@ -269,17 +270,16 @@ namespace Ombi
|
|||
var indexHtml = await File.ReadAllTextAsync(indexPath);
|
||||
var sb = new StringBuilder(indexHtml);
|
||||
|
||||
var headPosition = indexHtml.IndexOf("<script");
|
||||
var firstLinkPosition = indexHtml.IndexOf("<style type=");
|
||||
const string scriptRegex = "<script.type=.+>window.+=.+;<.script>";
|
||||
const string baseUrlRegex = "<base.href=\".+\">";
|
||||
|
||||
sb.Remove(headPosition, firstLinkPosition - headPosition - 6);
|
||||
indexHtml = Regex.Replace(indexHtml, scriptRegex, $"<script type='text/javascript'>window[\"baseHref\"] = '{trimmedBaseUrl}';</script>");
|
||||
|
||||
sb.Insert(headPosition + 6,
|
||||
$"<script type='text/javascript'>window[\"baseHref\"] = '{trimmedBaseUrl}';</script><base href=\"{trimmedBaseUrl}/\">");
|
||||
indexHtml = Regex.Replace(indexHtml, baseUrlRegex, $"<base href=\"{trimmedBaseUrl}/\">");
|
||||
|
||||
try
|
||||
{
|
||||
await File.WriteAllTextAsync(indexPath, sb.ToString());
|
||||
await File.WriteAllTextAsync(indexPath, indexHtml);
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue