Skip to content

Commit

Permalink
- Added extra fix for The Trove for checking if the correct directory…
Browse files Browse the repository at this point in the history
… is returned, and do not trim anymore because everything can start AND end with a space..
  • Loading branch information
KoalaBear84 committed Jul 12, 2020
1 parent 4b19b35 commit 884e85e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions OpenDirectoryDownloader/DirectoryParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ private static WebDirectory ParseSnifDirectoryListing(string baseUrl, WebDirecto

private static WebDirectory ParsePureDirectoryListing(ref string baseUrl, WebDirectory parsedWebDirectory, IHtmlDocument htmlDocument, IHtmlCollection<IElement> pureTableRows)
{
string urlFromBreadcrumbs = Uri.EscapeUriString(string.Join("/", htmlDocument.QuerySelectorAll(".breadcrumbs_main .breadcrumb").Where(b => !b.ClassList.Contains("smaller")).Select(b => b.TextContent.Trim())) + "/");
string urlFromBreadcrumbs = Uri.EscapeUriString(string.Join("/", htmlDocument.QuerySelectorAll(".breadcrumbs_main .breadcrumb").Where(b => !b.ClassList.Contains("smaller")).Select(b => b.TextContent)) + "/");

// Remove possible file part (index.html) from url
if (!string.IsNullOrWhiteSpace(Path.GetFileName(WebUtility.UrlDecode(baseUrl))))
Expand All @@ -504,7 +504,7 @@ private static WebDirectory ParsePureDirectoryListing(ref string baseUrl, WebDir
string urlFromBaseUrl = baseUrl.Remove(0, new Uri(baseUrl).Scheme.Length + new Uri(baseUrl).Host.Length + 3).Replace("/.", "/");
urlFromBaseUrl = urlFromBaseUrl.Replace("%23", "#");

if (urlFromBreadcrumbs == urlFromBaseUrl)
if (urlFromBreadcrumbs == urlFromBaseUrl || urlFromBreadcrumbs == Uri.EscapeUriString(urlFromBaseUrl))
{
IElement table = pureTableRows.First().Parent("table");

Expand Down

0 comments on commit 884e85e

Please sign in to comment.