GoogleChromeLabs / text-fragments-polyfill

Apache License 2.0
116 stars 27 forks source link

Link generation issue on NVidia.com #132

Open tomayac opened 2 years ago

tomayac commented 2 years ago

(Migrated from https://github.com/GoogleChromeLabs/link-to-text-fragment/issues/58, via @guihkx.)

When trying to highlight the following text:

March 29th, 2022 - Windows 473.33, Linux 470.62.26

From this page: https://developer.nvidia.com/vulkan-driver

Your extension generates the following URL:

https://developer.nvidia.com/vulkan-driver#:~:text=march%2029th%2C%202022%20-%20windows%20473.33%2C%20linux%20470.62.26

When you open the URL above on Firefox 98.0.2, it highlights the text successfully, but the same does not happen on Chrome 100.0.4896.60.

Using Chrome's built-in "Copy link to highlight" feature, this URL is generated instead (and it works on both Firefox and Chrome):

https://developer.nvidia.com/vulkan-driver#:~:text=March%2029th%2C%202022%20%2D%20Windows%20473.33%2C%20Linux%20470.62.26

Maybe it could help you find a solution.

Thank you for this extension by the way!

woto commented 2 years ago

Comparing with original link gotten from original implementation in Chrome I see two differences:

  1. The words are unreasonable downcased. It must be 'March', not 'march'
  2. hyphen character is not encoded. It must be '%2D', not '-'

Link gotten from original Chrome implementation of 'Copy link to highlight':

https://developer.nvidia.com/vulkan-driver#:~:text=March%2029th%2C%202022%20%2D%20Windows%20473.33%2C%20Linux%20470.62.26

Link gotten from Chrome extension "Copy link to selected text" (bugreported link):

https://developer.nvidia.com/vulkan-driver#:~:text=march%2029th%2C%202022%20-%20windows%20473.33%2C%20linux%20470.62.26

tomayac commented 2 years ago

@tfmar, would anyone from your team be able to debug what the issue is here?

woto commented 2 years ago

Downcasing happens here :thinking: https://github.com/GoogleChromeLabs/link-to-text-fragment/blob/main/fragment-generation-utils.js#L1000 https://github.com/GoogleChromeLabs/link-to-text-fragment/blob/main/fragment-generation-utils.js#L672