Actually choose the best adapter match

So it turns out the documentation here has been wrong the whole time! Who knew?

This PR follows #1320, and selects the best matching prefix from the dict in a _really stupid_ way. The _right_ way to do this would be to use a trie, but I thought we probably didn't want the cost of a new structure, especially as it's unlikely a user will mount a large number of adapters to any one session.

Let me know if you think that's a bad idea, and I'll whip up a quick trie and add it to this PR.