2 ms·
I’m curious: why does the default behavior do the magic replacement for absolute paths links but not for relative paths? Also, perhaps the CDN script snippets
by amluto 8mo ago
I’m curious: why does the default behavior do the magic replacement for absolute paths links but not for relative paths?
Also, perhaps the CDN script snippets in the getting started page should include the integrity attribute.
- amaury_bouchard 8mo agoGood points, thanks! On relative paths: the current behavior is intentional for simplicity. µJS checks whether the URL starts with a slash (but not a double slash) to identify internal links. No one has reported this as an issue so far, but it's a valid feature request and I'll keep it in mind for a future version. On the integrity attribute: the reason it was missing is that the library was evolving quickly and the hash would have changed with every release. Now that it's stable, I'll add it.
- amluto 8mo agoI have a project that has ordinary internal links, but they’re all relative because the entire project can be based at a variable path. If I were to adopt µJS, though, I would probably want to opt in on a per-link basis.
- amaury_bouchard 8mo agoThat's a valid use case. For opt-in per link, you can disable global link interception with `mu.init({ processLinks: false })` and then add `mu-url` explicitly to the links you want µJS to handle. For the variable base path scenario, the `urlPrefix` option in `mu.init()` might also help. It prepends a prefix to all fetched URLs. That said, proper support for relative paths is on the roadmap.
- amaury_bouchard 7mo agoBoth points are now addressed: relative paths are handled, and the documentation includes the integrity hash. Thanks for taking the time to suggest these improvements!