Move canonicalization outside _link_allowed()

[ci skip]