|
|
@ -20,6 +20,7 @@ using Microsoft.Extensions.Logging.Abstractions;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Ombi.Api.TheMovieDb.Models;
|
|
|
|
using Ombi.Api.TheMovieDb.Models;
|
|
|
|
using System.Net.Http;
|
|
|
|
using System.Net.Http;
|
|
|
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Ombi
|
|
|
|
namespace Ombi
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -269,17 +270,16 @@ namespace Ombi
|
|
|
|
var indexHtml = await File.ReadAllTextAsync(indexPath);
|
|
|
|
var indexHtml = await File.ReadAllTextAsync(indexPath);
|
|
|
|
var sb = new StringBuilder(indexHtml);
|
|
|
|
var sb = new StringBuilder(indexHtml);
|
|
|
|
|
|
|
|
|
|
|
|
var headPosition = indexHtml.IndexOf("<script");
|
|
|
|
const string scriptRegex = "<script.type=.+>window.+=.+;<.script>";
|
|
|
|
var firstLinkPosition = indexHtml.IndexOf("<style type=");
|
|
|
|
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,
|
|
|
|
indexHtml = Regex.Replace(indexHtml, baseUrlRegex, $"<base href=\"{trimmedBaseUrl}/\">");
|
|
|
|
$"<script type='text/javascript'>window[\"baseHref\"] = '{trimmedBaseUrl}';</script><base href=\"{trimmedBaseUrl}/\">");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await File.WriteAllTextAsync(indexPath, sb.ToString());
|
|
|
|
await File.WriteAllTextAsync(indexPath, indexHtml);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (UnauthorizedAccessException)
|
|
|
|
catch (UnauthorizedAccessException)
|
|
|
|
{
|
|
|
|
{
|
|
|
|