UNPKG

@stylable/core

Version:

CSS for Components

31 lines 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.string2varname = exports.filename2varname = exports.stripQuotation = void 0; /* eslint-disable no-control-regex */ function stripQuotation(str) { return str.replace(/^['"](.*?)['"]$/g, '$1'); } exports.stripQuotation = stripQuotation; function filename2varname(filename) { return string2varname(filename // remove extension (eg. .css) .replace(/(?=.*)\.\w+$/, '') // remove potential .st extension prefix .replace(/\.st$/, '')); } exports.filename2varname = filename2varname; function string2varname(str) { return (str // allow only letters, numbers, dashes, underscores, and non-ascii .replace(/[\x00-\x7F]+/gm, (matchAscii) => { return matchAscii.replace(/[^0-9a-zA-Z_-]/gm, ''); }) // replace multiple dashes with single dash .replace(/--+/gm, '-') // replace multiple underscores with single underscore .replace(/__+/gm, '_') // remove leading digits from start .replace(/^\d+/gm, '')); } exports.string2varname = string2varname; //# sourceMappingURL=string.js.map