diff --git a/js/usercss.js b/js/usercss.js index eb1a31dd..80315cdd 100644 --- a/js/usercss.js +++ b/js/usercss.js @@ -446,6 +446,9 @@ var usercss = (function () { parseStringToEnd(state); usercssData[state.key] = state.value; } + if (state.key === 'version') { + usercssData[state.key] = normalizeVersion(usercssData[state.key]); + } if (METAS[state.key]) { style[state.key] = usercssData[state.key]; } @@ -460,6 +463,14 @@ var usercss = (function () { return style; } + function normalizeVersion(version) { + // https://docs.npmjs.com/misc/semver#versions + if (version[0] === 'v' || version[0] === '=') { + return version.slice(1); + } + return version; + } + function buildCode(style) { const {usercssData: {preprocessor, vars}, sourceCode} = style; let builder;