Skip to content

Commit

Permalink
Fix #36. Now defaultProtocol accepts scheme name (e.g. https) without…
Browse files Browse the repository at this point in the history
… trailing colon.
  • Loading branch information
CXuesong committed Mar 12, 2018
1 parent 5bd1c79 commit 75b7f2e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions WikiClientLibrary/Infrastructures/MediaWikiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public static JsonSerializer CreateWikiJsonSerializer()
/// Converts the specified relative protocol URL (starting with <c>//</c>) to absolute protocol URL.
/// </summary>
/// <param name="relativeProtocolUrl">The URL to be converted.</param>
/// <param name="defaultProtocol">For protocol-relative URL, (e.g. <c>//en.wikipedia.org/</c>)
/// specifies the default protocol to use. (e.g. <c>https:</c>)</param>
/// <param name="defaultProtocol">For protocol-relative URL,(e.g. <c>//en.wikipedia.org/</c>),
/// specifies the default protocol to use. (e.g. <c>https</c>)</param>
/// <exception cref="ArgumentNullException">Either <paramref name="relativeProtocolUrl"/> or <paramref name="defaultProtocol"/> is <c>null</c>.</exception>
/// <returns>The URL with absolute protocol. If the specified URL is not a relative protocol URL,
/// it will be returned directly.</returns>
Expand All @@ -45,20 +45,20 @@ 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;
}

/// <summary>
/// Combines a base URL and a relative URL, using <c>https:</c> for relative protocol URL.
/// Combines a base URL and a relative URL, using <c>https</c> for relative protocol URL.
/// </summary>
/// <param name="baseUrl">The base absolute URL. Can be relative protocol URL.</param>
/// <param name="relativeUrl">The relative URL.</param>
/// <exception cref="ArgumentNullException">Either <paramref name="baseUrl"/> or <paramref name="relativeUrl"/> is <c>null</c>.</exception>
/// <returns>The combined URL with absolute protocol.</returns>
public static string MakeAbsoluteUrl(string baseUrl, string relativeUrl)
{
return MakeAbsoluteUrl(baseUrl, relativeUrl, "https:");
return MakeAbsoluteUrl(baseUrl, relativeUrl, "https");
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions WikiClientLibrary/Sites/SiteInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public string MakeArticleUrl(string title)
/// Makes the full URL to the page of specified title.
/// </summary>
/// <param name="title">The title of the article.</param>
/// <param name="defaultProtocol">For protocol-relative URL, (e.g. <c>//en.wikipedia.org/</c>)
/// specifies the default protocol to use. (e.g. <c>https:</c>)</param>
/// <param name="defaultProtocol">For protocol-relative URL (e.g. <c>//en.wikipedia.org/</c>),
/// specifies the default protocol to use. (e.g. <c>https</c>)</param>
/// <exception cref="ArgumentNullException">Either <paramref name="title"/> or <paramref name="defaultProtocol"/> is <c>null</c>.</exception>
/// <returns>The full URL of the article.</returns>
public string MakeArticleUrl(string title, string defaultProtocol)
Expand Down

0 comments on commit 75b7f2e

Please sign in to comment.