binyamin / eleventy-garden

:seedling: A starter site for building a mind garden with eleventy
https://eleventy-garden.netlify.app
MIT License
450 stars 48 forks source link

Normalize backlink slug comparison #91

Closed jacobbudin closed 1 year ago

jacobbudin commented 1 year ago

Fixes #87

The issue demonstrated in jrekier/mind-garden is that while the strings represent the same characters, they are not byte identical. (See "proof" below.) Calling String.prototype.normalize() before the comparison returns the expected match.

$ echo "Poincaré equation" | hexdump -C
00000000  50 6f 69 6e 63 61 72 c3  a9 20 65 71 75 61 74 69  |Poincaré equati|
00000010  6f 6e 0a                                          |on.|
00000013
$ echo "Poincaré equation" | hexdump -C
00000000  50 6f 69 6e 63 61 72 65  cc 81 20 65 71 75 61 74  |Poincare?. equat|
00000010  69 6f 6e 0a                                       |ion.|
00000014
binyamin commented 1 year ago

@jrekier Does this solve your issue (#87)?

binyamin commented 1 year ago

@jacobbudin Thanks for your work. I extracted the backlinks logic to a plugin (binyamin/eleventy-plugin-backlinks). If you want to patch it there too, go ahead.

jacobbudin commented 1 year ago

@binyamin Sure: https://github.com/binyamin/eleventy-plugin-backlinks/pull/2. Hope this helps.

jrekier commented 1 year ago

@binyamin looks like it :) Thanks @jacobbudin, I'd never have thought of that.