- Linting (ESLint): Simplify regexes
- npm: Update scripts to reflect removal of `all_tests.html`; remove `browser-test` script - npm: Update devDeps
This commit is contained in:
@@ -152,7 +152,7 @@ function build (opts) {
|
||||
|
||||
// compress spaces
|
||||
svg.compressSpaces = function (s) {
|
||||
return s.replace(/[\s\r\t\n]+/gm, ' ');
|
||||
return s.replace(/\s+/gm, ' ');
|
||||
};
|
||||
|
||||
// ajax
|
||||
@@ -302,7 +302,7 @@ function build (opts) {
|
||||
}
|
||||
|
||||
getUnits () {
|
||||
return String(this.value).replace(/[0-9.-]/g, '');
|
||||
return String(this.value).replace(/[\d.-]/g, '');
|
||||
}
|
||||
|
||||
// get the length as pixels
|
||||
@@ -1254,8 +1254,8 @@ function build (opts) {
|
||||
.replace(/,/gm, ' ') // get rid of all commas
|
||||
.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from commands
|
||||
.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from commands
|
||||
.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm, '$1 $2') // separate commands from points
|
||||
.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from points
|
||||
.replace(/([MmZzLlHhVvCcSsQqTtAa])(\S)/gm, '$1 $2') // separate commands from points
|
||||
.replace(/(\S)([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from points
|
||||
.replace(/(\d)([+-])/gm, '$1 $2') // separate digits when no comma
|
||||
.replace(/(\.\d*)(\.)/gm, '$1 $2') // separate digits when no comma
|
||||
.replace(/([Aa](\s+\d+)(\s+\d+)(\s+\d+))\s+([01])\s*([01])/gm, '$1 $5 $6 '); // shorthand elliptical arc path syntax
|
||||
@@ -2367,7 +2367,7 @@ function build (opts) {
|
||||
css += nodeValue;
|
||||
});
|
||||
// remove comments
|
||||
css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // eslint-disable-line unicorn/no-unsafe-regex
|
||||
css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^\s*\/\/.*)/gm, ''); // eslint-disable-line unicorn/no-unsafe-regex
|
||||
// replace whitespace
|
||||
css = svg.compressSpaces(css);
|
||||
const cssDefs = css.split('}');
|
||||
|
||||
@@ -170,7 +170,7 @@ const colorDefs = [
|
||||
}
|
||||
},
|
||||
{
|
||||
re: /^(\w{1})(\w{1})(\w{1})$/,
|
||||
re: /^(\w)(\w)(\w)$/,
|
||||
// re: /^(?<r>\w{1})(?<g>\w{1})(?<b>\w{1})$/,
|
||||
example: ['#fb0', 'f0f'],
|
||||
process (_, ...bits) {
|
||||
|
||||
@@ -549,17 +549,17 @@ const jPicker = function ($) {
|
||||
color.val('v', value.val(), e.target);
|
||||
break;
|
||||
case hex.get(0):
|
||||
hex.val(hex.val().replace(/[^a-fA-F0-9]/g, '').toLowerCase().substring(0, 6));
|
||||
hex.val(hex.val().replace(/[^a-fA-F\d]/g, '').toLowerCase().substring(0, 6));
|
||||
bindedHex && bindedHex.val(hex.val());
|
||||
color.val('hex', hex.val() !== '' ? hex.val() : null, e.target);
|
||||
break;
|
||||
case bindedHex && bindedHex.get(0):
|
||||
bindedHex.val(bindedHex.val().replace(/[^a-fA-F0-9]/g, '').toLowerCase().substring(0, 6));
|
||||
bindedHex.val(bindedHex.val().replace(/[^a-fA-F\d]/g, '').toLowerCase().substring(0, 6));
|
||||
hex.val(bindedHex.val());
|
||||
color.val('hex', bindedHex.val() !== '' ? bindedHex.val() : null, e.target);
|
||||
break;
|
||||
case ahex && ahex.get(0):
|
||||
ahex.val(ahex.val().replace(/[^a-fA-F0-9]/g, '').toLowerCase().substring(0, 2));
|
||||
ahex.val(ahex.val().replace(/[^a-fA-F\d]/g, '').toLowerCase().substring(0, 2));
|
||||
color.val('a', !isNullish(ahex.val()) ? parseInt(ahex.val(), 16) : null, e.target);
|
||||
break;
|
||||
}
|
||||
@@ -1056,7 +1056,7 @@ const jPicker = function ($) {
|
||||
*/
|
||||
validateHex (hex) {
|
||||
// if (typeof hex === 'object') return '';
|
||||
hex = hex.toLowerCase().replace(/[^a-f0-9]/g, '');
|
||||
hex = hex.toLowerCase().replace(/[^a-f\d]/g, '');
|
||||
if (hex.length > 8) hex = hex.substring(0, 8);
|
||||
return hex;
|
||||
},
|
||||
|
||||
@@ -3287,8 +3287,8 @@ function selectWord (evt) {
|
||||
|
||||
const index = getIndexFromPoint(pt.x, pt.y);
|
||||
const str = curtext.textContent;
|
||||
const first = str.substr(0, index).replace(/[a-z0-9]+$/i, '').length;
|
||||
const m = str.substr(index).match(/^[a-z0-9]+/i);
|
||||
const first = str.substr(0, index).replace(/[a-z\d]+$/i, '').length;
|
||||
const m = str.substr(index).match(/^[a-z\d]+/i);
|
||||
const last = (m ? m[0].length : 0) + index;
|
||||
setSelection(first, last);
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ export const init = function (editorContext) {
|
||||
* @todo This might be needed in other places `parseFromString` is used even without LGTM flagging
|
||||
*/
|
||||
export const dropXMLInteralSubset = (str) => {
|
||||
return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?\]>)/, '$1$2');
|
||||
return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?]>)/, '$1$2');
|
||||
// return str.replace(/(?<doctypeOpen><!DOCTYPE\s+\w*\s*\[).*(?<doctypeClose>\?\]>)/, '$<doctypeOpen>$<doctypeClose>');
|
||||
};
|
||||
|
||||
@@ -208,7 +208,7 @@ export function decode64 (input) {
|
||||
}
|
||||
|
||||
// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
|
||||
input = input.replace(/[^A-Za-z0-9+/=]/g, '');
|
||||
input = input.replace(/[^A-Za-z\d+/=]/g, '');
|
||||
|
||||
let output = '';
|
||||
let i = 0;
|
||||
|
||||
@@ -7937,7 +7937,7 @@
|
||||
*/
|
||||
|
||||
var dropXMLInteralSubset = function dropXMLInteralSubset(str) {
|
||||
return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?\]>)/, '$1$2'); // return str.replace(/(?<doctypeOpen><!DOCTYPE\s+\w*\s*\[).*(?<doctypeClose>\?\]>)/, '$<doctypeOpen>$<doctypeClose>');
|
||||
return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?]>)/, '$1$2'); // return str.replace(/(?<doctypeOpen><!DOCTYPE\s+\w*\s*\[).*(?<doctypeClose>\?\]>)/, '$<doctypeOpen>$<doctypeClose>');
|
||||
};
|
||||
/**
|
||||
* Converts characters in a string to XML-friendly entities.
|
||||
@@ -8017,7 +8017,7 @@
|
||||
} // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
|
||||
|
||||
|
||||
input = input.replace(/[^A-Za-z0-9+/=]/g, '');
|
||||
input = input.replace(/[^A-Za-z\d+/=]/g, '');
|
||||
var output = '';
|
||||
var i = 0;
|
||||
|
||||
@@ -17104,8 +17104,8 @@
|
||||
var pt = screenToPt(mouseX, mouseY);
|
||||
var index = getIndexFromPoint(pt.x, pt.y);
|
||||
var str = curtext.textContent;
|
||||
var first = str.substr(0, index).replace(/[a-z0-9]+$/i, '').length;
|
||||
var m = str.substr(index).match(/^[a-z0-9]+/i);
|
||||
var first = str.substr(0, index).replace(/[a-z\d]+$/i, '').length;
|
||||
var m = str.substr(index).match(/^[a-z\d]+/i);
|
||||
var last = (m ? m[0].length : 0) + index;
|
||||
setSelection(first, last); // Set tripleclick
|
||||
|
||||
@@ -25473,19 +25473,19 @@
|
||||
break;
|
||||
|
||||
case hex.get(0):
|
||||
hex.val(hex.val().replace(/[^a-fA-F0-9]/g, '').toLowerCase().substring(0, 6));
|
||||
hex.val(hex.val().replace(/[^a-fA-F\d]/g, '').toLowerCase().substring(0, 6));
|
||||
bindedHex && bindedHex.val(hex.val());
|
||||
color.val('hex', hex.val() !== '' ? hex.val() : null, e.target);
|
||||
break;
|
||||
|
||||
case bindedHex && bindedHex.get(0):
|
||||
bindedHex.val(bindedHex.val().replace(/[^a-fA-F0-9]/g, '').toLowerCase().substring(0, 6));
|
||||
bindedHex.val(bindedHex.val().replace(/[^a-fA-F\d]/g, '').toLowerCase().substring(0, 6));
|
||||
hex.val(bindedHex.val());
|
||||
color.val('hex', bindedHex.val() !== '' ? bindedHex.val() : null, e.target);
|
||||
break;
|
||||
|
||||
case ahex && ahex.get(0):
|
||||
ahex.val(ahex.val().replace(/[^a-fA-F0-9]/g, '').toLowerCase().substring(0, 2));
|
||||
ahex.val(ahex.val().replace(/[^a-fA-F\d]/g, '').toLowerCase().substring(0, 2));
|
||||
color.val('a', !isNullish$1(ahex.val()) ? parseInt(ahex.val(), 16) : null, e.target);
|
||||
break;
|
||||
}
|
||||
@@ -26124,7 +26124,7 @@
|
||||
*/
|
||||
validateHex: function validateHex(hex) {
|
||||
// if (typeof hex === 'object') return '';
|
||||
hex = hex.toLowerCase().replace(/[^a-f0-9]/g, '');
|
||||
hex = hex.toLowerCase().replace(/[^a-f\d]/g, '');
|
||||
if (hex.length > 8) hex = hex.substring(0, 8);
|
||||
return hex;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user