GoogleChromeLabs / link-to-text-fragment

Browser extension that allows for linking to arbitrary text fragments.
https://chrome.google.com/webstore/detail/link-to-text-fragment/pbcodcjpfjdpcineamnnmbkkmkdpajjg
Apache License 2.0
412 stars 33 forks source link

strip whitespace for text, when generating a link #60

Closed FranklinYu closed 2 years ago

FranklinYu commented 2 years ago

Platform

Steps to reproduce

  1. Navigate to https://unicode-table.com/en/00BE/
  2. Triple-click the paragraph “Vulgar Fraction Three Quarters. Latin-1 Supplement.” This should select (highlight) the paragraph.
  3. Generate a link with this selection via the context menu.
  4. Open the URL with Firefox. The paragraph is highlighted, as expected.
  5. Open the same URL with Chrome. The paragraph isn’t highlighted.

details

In the generated link, the text value starts with a space, which is probably because the textContent of the <p> itself starts with the space. However, Chrome might trim the space when matching. If I manually remove the %20 in text field, Chrome would be able to highlight the text, as expected. I’m not sure whether this issue counts as a bug or a feature request: it does sound broken, but technically it’s kind of expected (we might as well blame the website).

tomayac commented 2 years ago

Closing in favor of https://github.com/GoogleChromeLabs/text-fragments-polyfill/issues/135.