Since this was introduced Auto-inserting Stack Overflow affiliate into all Amazon book links (of which I am very much in favor of course) [I like my sites 100% free :D] I happened to come across a link in this post:


which is an answer, and which has two amazon links:

[5]: http://www.amazon.com/C-Programming-Language-e/dp/B001K6L7SW/ref=dp_kinw_strp_1
[6]: http://www.amazon.com/Essential-4-0-Microsoft-NET-Development/dp/0321694694

but which only one of them gets converted to a rads link. This is not cool for SO.

ok, well I thought it would look funny and get me upboats but the "proposed solution" really just looks dumb. removing (there's always revision history)

  • 6
    Now waiting up to 30 minutes for GraceNote to tell me what this is a duplicate of :p ... I <3 you Grace! You're just smarter than the search engine ;)
    – jcolebrand
    Apr 13 '11 at 1:59
  • Wonder if you can just pick up that 10-character ASIN
    – random
    Apr 13 '11 at 2:02
  • @Random I was thinking that but what if there's two 10 character ASIN in there for some ungodly reason (I told you it was the naieve "it only ever happens this way approach") Especially since http://www.amazon.com/dp/B001K6L7SW is also valid for that link in particular.
    – jcolebrand
    Apr 13 '11 at 2:06
  • Are you going to account for the amzn.to links as well?
    – random
    Apr 13 '11 at 2:07
  • @Random do they already? tried amzn.to/dp/B001K6L7SW and it didn't like it. Since it's a bit.ly I don't think those will be processable like this. Got a valid one offhand?
    – jcolebrand
    Apr 13 '11 at 2:11
  • amzn.com/0898153883 - How about the ones who don't use www. since that also works.
    – random
    Apr 13 '11 at 2:14
  • Ok, I can see I should be honest that if I really wanted this to work I would send a http request off to amazon for the URL, see that Amazon parsed it, then I would get the page back and look in the head for this <link rel="canonical" href="http://www.amazon.com/Essential-4-0-Microsoft-NET-Development/dp/0321694694"> and then I would process my link using their canonical link. The above stuff in my question was more for fun than for actual right. I imagine the SEI code uses LINQ and regexes right now. (cc @random)
    – jcolebrand
    Apr 13 '11 at 2:16

We recently made a lot of adjustments to make the amazon referral linking* much more flexible.

These cases should all be fixed.

* we don't do this in comments because comments are rendered on the fly each time.

  • Couldn't you do this on the fly with JavaScript for the comments? It's just checking and modifying the href attribute of each a tag, and you could narrow this down by only checking in comments.
    – wizzwizz4
    Jan 26 '16 at 17:51

You must log in to answer this question.

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