Yesterday someone edited my question and converted all of my un-encrypted http:// links to protocol relative //.

At first I was like "Sweet catch!" because I'm always getting on to our webmaster for a nasty habit they have of hard-coding insecure sources to images, js, and iframes with src="http://... which flat out won't work over a secure https:// connection. (At least not without a bunch of permissive "I understand the consequences" clicks on behalf of the client.) So I try to use protocol relative links across the board for a lot of reasons.

But then I noticed all of those linked questions I made to other SE posts disappeared from the "Linked Questions" sidebar. So to test, I rolled back those changes, and the sidebar returned.

This question is very closely related to Relative links are ignored by “Linked Questions”, but I expect some more trickery is involved with host (or folder) relative links rather than protocol relative links.

It's also interesting to note that both http:// and https:// links are recognized as a "linked question." So my specific question is: Why aren't protocol relative links recognized as linked questions? But this question can be deleted if we can get an authoritative answer to How does Stack Overflow find 'Linked' questions?


Because this:

public static Regex GetQuestionUrlRegex()
    return new Regex(@"https?://" + Regex.Escape(Current.Site.BaseHostAddress) + @"(?:/q(uestions)?/(?<qid>\d+)|/a/(?<aid>\d+))", RegexOptions.IgnoreCase);
  • 1
    Are you allowed to expose source code out in the open? ;-) Jun 16 '16 at 21:28
  • 5
    @ShadowWizard We would never...
    – Adam Lear StaffMod
    Jun 16 '16 at 21:34
  • @Adam touché... Jun 16 '16 at 21:44
  • Since neither my c# nor regex skills are worth a dime, can you tell me how difficult this would be to modify it to allow a blank http(s)? Jun 17 '16 at 2:39
  • Could be as simple as deleting 7 characters, but might get complicated if this is used elsewhere. Regardless, one more thing that'll have to be fixed eventually.
    – Shog9
    Jun 17 '16 at 4:06
  • This regex has since changed to cover relative links. Can you please edit this with the latest regex? Sep 27 '19 at 17:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .