From f032cc8cf6958133b4acd1b616ee96332320d60d Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 16 Aug 2015 01:50:34 -0700 Subject: [PATCH] Support for not adding a hash to some index elements --- .../Frontend/Mappers/IndexHtmlMapper.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Api/Frontend/Mappers/IndexHtmlMapper.cs b/src/NzbDrone.Api/Frontend/Mappers/IndexHtmlMapper.cs index 42adefe0d..87810d782 100644 --- a/src/NzbDrone.Api/Frontend/Mappers/IndexHtmlMapper.cs +++ b/src/NzbDrone.Api/Frontend/Mappers/IndexHtmlMapper.cs @@ -17,7 +17,7 @@ namespace NzbDrone.Api.Frontend.Mappers private readonly IAnalyticsService _analyticsService; private readonly Func _cacheBreakProviderFactory; private readonly string _indexPath; - private static readonly Regex ReplaceRegex = new Regex("(?<=(?:href|src)=\").*?(css|js|png|ico|ics)(?=\")", RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex ReplaceRegex = new Regex(@"(?:(?href|src)=\"")(?.*?(?css|js|png|ico|ics))(?:\"")(?:\s(?data-no-hash))?", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static String API_KEY; private static String URL_BASE; @@ -85,8 +85,19 @@ namespace NzbDrone.Api.Frontend.Mappers text = ReplaceRegex.Replace(text, match => { - var url = cacheBreakProvider.AddCacheBreakerToPath(match.Value); - return URL_BASE + url; + string url; + + if (match.Groups["nohash"].Success) + { + url = match.Groups["path"].Value; + } + + else + { + url = cacheBreakProvider.AddCacheBreakerToPath(match.Groups["path"].Value); + } + + return String.Format("{0}=\"{1}{2}\"", match.Groups["attribute"].Value, URL_BASE, url); }); text = text.Replace("API_ROOT", URL_BASE + "/api");