Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to request globally unique ids #10336

Open
chris48s opened this issue Jul 5, 2024 · 0 comments
Open

Allow user to request globally unique ids #10336

chris48s opened this issue Jul 5, 2024 · 0 comments
Labels
npm-package Badge generation and badge templates

Comments

@chris48s
Copy link
Member

chris48s commented Jul 5, 2024

Discussed in #10321

The IDs on the linearGradient and clipPath SVG elements are the same for every badge. This means the IDs are unique within any given SVG document, but if you embed multiple SVGs inline in a single HTML document then the IDs aren't unique within the HTML page.

This leads to this behaviour:

image

This is a fairly uncommon use-case and for shields.io itself it is useful that the IDs are single character. However, it would be useful for the makeBadge() function to expose a non-default option which allows the user to specify they want globally unique IDs.

We could do this without adding any additional dependency by using crypto.randomUUID() from the node standard library to generate the IDs:

const { randomUUID } = require('crypto');
console.log(randomUUID());
@chris48s chris48s added the npm-package Badge generation and badge templates label Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
npm-package Badge generation and badge templates
Projects
None yet
Development

No branches or pull requests

1 participant