lovell / limax

Node.js module to generate URL slugs. Another one? This one cares about i18n and transliterates non-Latin scripts to conform to the RFC3986 standard. Mostly API-compatible with similar modules.
Apache License 2.0
587 stars 50 forks source link

Mapping of umlauts broken #50

Open qqilihq opened 1 year ago

qqilihq commented 1 year ago

Hi all,

previous versions of Limax mapped German umlauts to the proper counterpart (e.g. ü will become ue). With the change in #44 and 4.0 unfortunately this breaks, and ü will now be mapped to a simple u which would be considered “less correct” in German.

Also, trying to fix it via a custom mapping will not help, as the _.deburr replacement happens without considering the given mappings. Our current workaround replaces them before applying limax:

  const fixedMapping = {
    ä: 'ae',
    Ä: 'Ae',
    ö: 'oe',
    Ö: 'Oe',
    ü: 'ue',
    Ü: 'Ue'
  };
  let fixedInput = input;
  for (const mapping of Object.entries(fixedMapping)) {
    fixedInput = fixedInput.replaceAll(mapping[0], mapping[1]);
  }
lovell commented 1 year ago

Thanks for reporting, as I mentioned in https://github.com/lovell/limax/issues/49#issuecomment-1642683049 it's probably a good time to vendor the upstream speakingurl and patch all the known bugs, which should allow us to drop the deburr dependency.

Happy to accept a PR to directly add the source code of https://github.com/pid/speakingurl/blob/master/lib/speakingurl.js (with the BSD-3-Clause licence added as a comment/header) instead of using it as a dependency.

qqilihq commented 1 year ago

Thank you for the feedback - I'll see if I find the time to come up with a MR during the next week 👍