Fix: normalize version

This commit is contained in:
eight 2017-10-06 17:09:28 +08:00
parent da5626a6d7
commit 56e669fbcf

View File

@ -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;