hypothesis / client

The Hypothesis web-based annotation client.
Other
637 stars 197 forks source link

annotation fails for tweet with camelcased username #706

Open judell opened 6 years ago

judell commented 6 years ago

Sample tweet: https://twitter.com/realDonaldTrump/status/979326715272065024

Annotation: https://hypothes.is/api/search?uri=https://twitter.com/realDonaldTrump/status/979326715272065024

Expected result: Annotation appears in H client at the tweet URL

What happens: It doesn't

Why not: Twitter declares:

<link rel="canonical" href="https://twitter.com/realdonaldtrump/status/979326715272065024">

so the client's search ends up being

https://hypothes.is/api/search?uri=https://twitter.com/realdonaldtrump/status/979326715272065024

which fails.

Possible solution: When the search URI obtained from the target page is a case-insensitive match for the rel="canonical", include both in the set of URIs the client searches for.

Here's where such an intervention might happen:

https://github.com/hypothesis/client/blob/2578fefde9011a907411e1b75bad93d04b539445/src/sidebar/store/modules/frames.js#L74

Both variants are available in that context:

image

segdeha commented 6 years ago

Unless there's something I'm overlooking, I'd be in favor of treating rel="canonical" links (specifically host names and paths, not query parameters) as case-insensitive by default. It's probably extremely rare that a site maintainer intends to serve different resources from URLs that are different in case only.

judell commented 6 years ago

case-insensitive by default

Yeah, that's probably fine.