This used to be an answer. Now it is a feature request.
The Autocard feature for Magic: the Gathering was updated in 2016. Since then the community has discovered a couple of bugs. We also found a solution that addresses those bugs, doesn't reintroduce old bugs, and as a bonus adds support for multiple languages.
Here are some test cases from bugs we've had in the past:
- Regular cards (Lightning Bolt)
- Cards with apostrophes (Death's Shadow)
- Single word cards whose names are a subset of another card (Island, Curiousity)
- Double word cards whose names are a subset of another card (Sun Titan)
- Cards that are also an avatar (Platinum Angel)
- Both an apostrophe, and an avatar (Hell's Caretaker)
A separate bug is that whilst we usually link card names in English, if a visitor's PC is configured to another language (e.g. German or Japanese) Gatherer completely fails to find the card. (Because it looks for the card name in their language's list, not in the English list.)
Test Results for the current autocard link as of 2018-05-27
See the test run here. If the link took me directly to the one card I was searching for, it passed. Otherwise it failed. I copied the URLs that were produced, in case they change retroactively. The base URL is always gatherer.wizards.com/Pages/Search/Default.aspx.
- Pass:
[mtg:Lightning Bolt]
->...?name=%2b%5bLightning%20Bolt%5d
- Pass:
[mtg:Death's Shadow]
->...?name=%2b%5bDeath%27s%5d%2b%5bShadow%5d
- Fail:
[mtg:Island]
->...?name=%2b%5bIsland%5d
- Pass:
[mtg:Sun Titan]
->...?name=%2b%5bSun%20Titan%5d
- Fail:
[mtg:Platinum Angel]
->...?name=%2b%5bPlatinum%20Angel%5d
- Pass:
[mtg:Hell's Caretaker]
->...?name=%2b%5bHell%27s%5d%2b%5bCaretaker%5d
Solution — A new Gatherer autocard format
The community came up with a solution that is almost a one-liner in JavaScript.
function urlFrom(cardName) {
const baseUrl = 'http://gatherer.wizards.com/Pages/Card/Details.aspx'
var queryString = '?name=' + encodeURIComponent(cardName)
return baseUrl + queryString;
}
Or:
http://gatherer.wizards.com/Pages/Card/Details.aspx?name=Platinum%20Angel
No brackets or pluses. Using this URL also fixes the language bug.
Here's a fiddle demonstrating that the solution works. The links in this fiddle point to every card we've found that may cause bugs for Autocard linking (or are bug examples), and all the links pass.
https://jsfiddle.net/ws165r64/52/ (See doppelgreener's answer for a fiddle with a more comprehensive test suite)