From 75b7f2e2a719a4dc70460e511e2e82790a410d06 Mon Sep 17 00:00:00 2001 From: forest93 Date: Mon, 12 Mar 2018 17:18:59 +0800 Subject: [PATCH] Fix #36. Now defaultProtocol accepts scheme name (e.g. https) without trailing colon. --- WikiClientLibrary/Infrastructures/MediaWikiHelper.cs | 10 +++++----- WikiClientLibrary/Sites/SiteInfo.cs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/WikiClientLibrary/Infrastructures/MediaWikiHelper.cs b/WikiClientLibrary/Infrastructures/MediaWikiHelper.cs index 4fdb67160..57d95008c 100644 --- a/WikiClientLibrary/Infrastructures/MediaWikiHelper.cs +++ b/WikiClientLibrary/Infrastructures/MediaWikiHelper.cs @@ -35,8 +35,8 @@ public static JsonSerializer CreateWikiJsonSerializer() /// Converts the specified relative protocol URL (starting with //) to absolute protocol URL. /// /// The URL to be converted. - /// For protocol-relative URL, (e.g. //en.wikipedia.org/) - /// specifies the default protocol to use. (e.g. https:) + /// For protocol-relative URL,(e.g. //en.wikipedia.org/), + /// specifies the default protocol to use. (e.g. https) /// Either or is null. /// The URL with absolute protocol. If the specified URL is not a relative protocol URL, /// it will be returned directly. @@ -45,12 +45,12 @@ public static string MakeAbsoluteProtocol(string relativeProtocolUrl, string def if (relativeProtocolUrl == null) throw new ArgumentNullException(nameof(relativeProtocolUrl)); if (defaultProtocol == null) throw new ArgumentNullException(nameof(defaultProtocol)); var url = relativeProtocolUrl; - if (url.StartsWith("//")) url = defaultProtocol + url; + if (url.StartsWith("//")) url = defaultProtocol + ":" + url; return url; } /// - /// Combines a base URL and a relative URL, using https: for relative protocol URL. + /// Combines a base URL and a relative URL, using https for relative protocol URL. /// /// The base absolute URL. Can be relative protocol URL. /// The relative URL. @@ -58,7 +58,7 @@ public static string MakeAbsoluteProtocol(string relativeProtocolUrl, string def /// The combined URL with absolute protocol. public static string MakeAbsoluteUrl(string baseUrl, string relativeUrl) { - return MakeAbsoluteUrl(baseUrl, relativeUrl, "https:"); + return MakeAbsoluteUrl(baseUrl, relativeUrl, "https"); } /// diff --git a/WikiClientLibrary/Sites/SiteInfo.cs b/WikiClientLibrary/Sites/SiteInfo.cs index 5f3b43b52..3e82c7e17 100644 --- a/WikiClientLibrary/Sites/SiteInfo.cs +++ b/WikiClientLibrary/Sites/SiteInfo.cs @@ -85,8 +85,8 @@ public string MakeArticleUrl(string title) /// Makes the full URL to the page of specified title. /// /// The title of the article. - /// For protocol-relative URL, (e.g. //en.wikipedia.org/) - /// specifies the default protocol to use. (e.g. https:) + /// For protocol-relative URL (e.g. //en.wikipedia.org/), + /// specifies the default protocol to use. (e.g. https) /// Either or is null. /// The full URL of the article. public string MakeArticleUrl(string title, string defaultProtocol)