From e918dbccb0cab414a28646c49dcc6a49eb725cfb Mon Sep 17 00:00:00 2001 From: Bartek Fabiszewski Date: Sun, 16 Feb 2020 19:16:58 +0100 Subject: [PATCH] Prefer template strings --- js/src/ajax.js | 4 ++-- js/src/utils.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/js/src/ajax.js b/js/src/ajax.js index b711873..a9443ef 100644 --- a/js/src/ajax.js +++ b/js/src/ajax.js @@ -91,14 +91,14 @@ export default class uAjax { } else { for (const key in data) { if (data.hasOwnProperty(key)) { - params.push(key + '=' + encodeURIComponent(data[key])); + params.push(`${key}=${encodeURIComponent(data[key])}`); } } body = params.join('&'); body = body.replace(/%20/g, '+'); } if (method === 'GET' && body.length) { - url += '?' + body; + url += `?${body}`; body = null; } xhr.open(method, url, true); diff --git a/js/src/utils.js b/js/src/utils.js index b6ade2d..6dfe77d 100644 --- a/js/src/utils.js +++ b/js/src/utils.js @@ -135,10 +135,10 @@ export default class uUtils { * @returns {string} */ static hexToRGBA(hex, opacity) { - return 'rgba(' + (hex = hex.replace('#', '')) - .match(new RegExp('(.{' + hex.length / 3 + '})', 'g')) + return `rgba(${(hex = hex.replace('#', '')) + .match(new RegExp(`(.{${hex.length / 3}})`, 'g')) .map((l) => parseInt(hex.length % 2 ? l + l : l, 16)) - .concat(opacity || 1).join(',') + ')'; + .concat(opacity || 1).join(',')})`; } /**