Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MediaWikiHelper.MakeAbsoluteUrl protocol not so intuitive #36

Closed
HarelM opened this issue Mar 11, 2018 · 2 comments
Closed

MediaWikiHelper.MakeAbsoluteUrl protocol not so intuitive #36

HarelM opened this issue Mar 11, 2018 · 2 comments

Comments

@HarelM
Copy link

HarelM commented Mar 11, 2018

The following call raises an exception:
I wanted to get a full URL of a page (I'm sure there is a simpler way but I couldn't find it...)

var allpagesGenerator = new AllPagesGenerator(_wikiSite)
{
    PaginationSize = 500
};
var results = await allpagesGenerator.EnumItemsAsync().ToList();
var page = new WikiPage(_wikiSite, results.First().Title);
var pageRelativeUrl = _wikiSite.SiteInfo.ArticlePath.Replace("$1", page.Title);
MediaWikiHelper.MakeAbsoluteUrl(_wikiSite.SiteInfo.ServerUrl + "/wiki", pageRelativeUrl, "http");

Apparently I need to send "http:" as protocol string, which I find not intuitive.

@HarelM
Copy link
Author

HarelM commented Mar 11, 2018

OK, I figured out how to get the content of a page (it was easier than I thought, now I feel dumb :-/).
Never-the-less the issue still exists...

@CXuesong
Copy link
Owner

CXuesong commented Mar 12, 2018

I believe the first time I wrote this part of code, I was only thinking of the simplicity on implementation… I will look into this and try to decide on a better solution, such as

  • http
  • http://

It seems that protocol-relative URLs are not part of the URI standard, and it is more likely of an ad-hoc resource locating solution for website migrating from HTTP to HTTPS without crossing the domain unnecessarily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants