diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 69cf3c4..1d26016 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,6 +1,6 @@ name: publish env: - VERSION: '0.18.4-preview' + VERSION: '0.18.5-preview' PRERELEASE: true on: push: diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e7bfe8b..1c67120 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.18.5-preview +### Fixed +- Retrieval of main page when title is explicit + ## 0.18.4-preview ### Fixed - URL generation for main titles diff --git a/src/Models/PageTitle.cs b/src/Models/PageTitle.cs index 035210c..c201fc1 100644 --- a/src/Models/PageTitle.cs +++ b/src/Models/PageTitle.cs @@ -353,16 +353,16 @@ public override string ToString() /// Gets a copy of this instance with the specified default title, if is /// currently . /// - /// - /// The domain of the page (if any). + /// + /// The default title to supply if the currrent title is . /// /// /// A new with set to the given default if it was /// previously , and the same and as this instance. /// - public PageTitle WithDefaultTitle(string defaultTitle) - => new(Title ?? defaultTitle, Namespace, Domain); + public PageTitle WithDefaultTitle(string title) + => new(Title ?? title, Namespace, Domain); /// /// Gets a copy of this instance with the specified . @@ -390,6 +390,19 @@ public PageTitle WithDefaultTitle(string defaultTitle) /// public PageTitle WithNamespace(string? @namespace) => new(Title, @namespace, Domain); + /// + /// Gets a copy of this instance with the specified title. + /// + /// + /// The title of the page (if any). + /// + /// + /// A new with set to the given value, and the same + /// and as this instance. + /// + public PageTitle WithTitle(string? title) + => new(title, Namespace, Domain); + internal void WriteUrl(StringWriter writer, WikiOptions wikiOptions) { if (!string.IsNullOrEmpty(Domain)) diff --git a/src/WikiExtensions.cs b/src/WikiExtensions.cs index e678c07..e1d51bb 100644 --- a/src/WikiExtensions.cs +++ b/src/WikiExtensions.cs @@ -1218,6 +1218,10 @@ public static async Task GetWikiPageAsync( bool noRedirect = false, bool exactMatchOnly = false) { + if (title.Title?.Equals(options.MainPageTitle) == true) + { + title = title.WithTitle(null); + } if (string.CompareOrdinal(title.Namespace, options.CategoryNamespace) == 0) { return await IPage