dylang / shortid

Short id generator. Url-friendly. Non-predictable. Cluster-compatible.

Home Page:https://www.npmjs.org/package/shortid

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Option to make CSS-selector-friendly ids?

JoshMcCullough opened this issue · comments

CSS selectors cannot start with a number, so shortid will generate non-compliant ids if you are using it to generate ids for HTML elements, which are later referenced from CSS.

It'd be nice to have a global option we can configure to ensure that generated ids do not start with a number. Though this is easily worked around by wrapping shortid:

import _shortid from 'shortid';

export const shortid = () => `_${_shortid}`;

Just something to consider.

Switching to nanoid due to deprecation.