Skip to content

Commit

Permalink
Fix Duplication Uri
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost1372 committed Nov 10, 2023
1 parent b8723c9 commit 495c9a8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
20 changes: 19 additions & 1 deletion dev/Tools/Common/AppHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public static string FixTitle(string title)
return title;
}

public static string ConcatenateUrls(string baseUrl, string relativeUrl)
private static string ConcatenateUrls(string baseUrl, string relativeUrl)
{
// Ensure baseUrl ends with a slash
if (!baseUrl.EndsWith("/"))
Expand All @@ -264,5 +264,23 @@ public static string ConcatenateUrls(string baseUrl, string relativeUrl)

return resultUrl;
}

public static string FixUriDuplication(string baseUrl, string relativeUrl)
{
var baseUrlUri = new Uri(baseUrl);

var baseUrlLeftPart = baseUrlUri.GetLeftPart(UriPartial.Authority);
var duplicateSection = baseUrl.Replace(baseUrlLeftPart, "");

if (duplicateSection.StartsWith("/"))
{
duplicateSection = duplicateSection.Substring(1);
}
if (relativeUrl.Contains(duplicateSection))
{
baseUrl = baseUrl.Replace(duplicateSection, "");
}
return ConcatenateUrls(baseUrl, relativeUrl);
}
}

2 changes: 1 addition & 1 deletion dev/TvTime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PublishProfile>win10-$(Platform).pubxml</PublishProfile>
<UseWinUI>true</UseWinUI>
<EnableMsixTooling>true</EnableMsixTooling>
<Version>4.8.0</Version>
<Version>4.8.1</Version>
<ImplicitUsings>true</ImplicitUsings>
<LangVersion>Latest</LangVersion>
<AccelerateBuildsInVisualStudio>False</AccelerateBuildsInVisualStudio>
Expand Down
2 changes: 1 addition & 1 deletion dev/ViewModels/Media/MediaDetailsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public List<BaseMediaTable> GetAllServerDetails(string content, BaseMediaTable b
continue;
}

var finalServer = ConcatenateUrls(baseMedia.Server, href);
var finalServer = FixUriDuplication(baseMedia.Server, href);

if (finalServer.Contains("dl5.dl1acemovies", StringComparison.OrdinalIgnoreCase))
{
Expand Down
2 changes: 1 addition & 1 deletion dev/ViewModels/Media/MediaViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public async Task GetAllServerDetails(string content, string server)
continue;
}

var finalServer = ConcatenateUrls(server, href);
var finalServer = FixUriDuplication(server, href);
if (finalServer.Contains("directadmin.com", StringComparison.OrdinalIgnoreCase) ||
finalServer.Contains("dl5.dl1acemovies") && (title.Equals("Home") ||
title.Equals("dl") || title.Equals("English") || title.Equals("Series") ||
Expand Down

0 comments on commit 495c9a8

Please sign in to comment.