1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-25 01:06:30 +00:00

Support for not adding a hash to some index elements

This commit is contained in:
Mark McDowall 2015-08-16 01:50:34 -07:00
parent 1a872035e7
commit f032cc8cf6

View file

@ -17,7 +17,7 @@ namespace NzbDrone.Api.Frontend.Mappers
private readonly IAnalyticsService _analyticsService; private readonly IAnalyticsService _analyticsService;
private readonly Func<ICacheBreakerProvider> _cacheBreakProviderFactory; private readonly Func<ICacheBreakerProvider> _cacheBreakProviderFactory;
private readonly string _indexPath; 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(@"(?:(?<attribute>href|src)=\"")(?<path>.*?(?<extension>css|js|png|ico|ics))(?:\"")(?:\s(?<nohash>data-no-hash))?", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static String API_KEY; private static String API_KEY;
private static String URL_BASE; private static String URL_BASE;
@ -85,8 +85,19 @@ namespace NzbDrone.Api.Frontend.Mappers
text = ReplaceRegex.Replace(text, match => text = ReplaceRegex.Replace(text, match =>
{ {
var url = cacheBreakProvider.AddCacheBreakerToPath(match.Value); string url;
return URL_BASE + 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"); text = text.Replace("API_ROOT", URL_BASE + "/api");