Support atompub service link with relative URL

This commit is contained in:
Andy Zivkovic 2016-10-09 07:31:11 +02:00
parent 7fb9626a9b
commit ccf7f9a540
1 changed files with 14 additions and 1 deletions

View File

@ -162,7 +162,7 @@ namespace OpenLiveWriter.BlogClient.Detection
_serviceName = atomProvider.Name;
_clientType = atomProvider.ClientType;
_blogName = string.Empty;
_postApiUrl = linkUrl;
_postApiUrl = GetAbsoluteUrl(url, linkUrl);
IBlogClient client = BlogClientManager.CreateClient(atomProvider.ClientType, _postApiUrl, _credentials);
client.VerifyCredentials();
@ -192,6 +192,19 @@ namespace OpenLiveWriter.BlogClient.Detection
return false;
}
private string GetAbsoluteUrl(string url, string linkUrl)
{
Uri absoluteUrl;
if (Uri.TryCreate(linkUrl, UriKind.Absolute, out absoluteUrl))
{
return linkUrl;
}
Uri baseUrl = new Uri(url);
absoluteUrl = new Uri(baseUrl, linkUrl);
return absoluteUrl.AbsoluteUri;
}
private class BloggerGeneratorCriterion : IElementPredicate
{
public bool IsMatch(Element e)