Prefer template strings

This commit is contained in:
Bartek Fabiszewski 2020-02-16 19:16:58 +01:00
parent ebde1f2756
commit e918dbccb0
2 changed files with 5 additions and 5 deletions

View File

@ -91,14 +91,14 @@ export default class uAjax {
} else { } else {
for (const key in data) { for (const key in data) {
if (data.hasOwnProperty(key)) { if (data.hasOwnProperty(key)) {
params.push(key + '=' + encodeURIComponent(data[key])); params.push(`${key}=${encodeURIComponent(data[key])}`);
} }
} }
body = params.join('&'); body = params.join('&');
body = body.replace(/%20/g, '+'); body = body.replace(/%20/g, '+');
} }
if (method === 'GET' && body.length) { if (method === 'GET' && body.length) {
url += '?' + body; url += `?${body}`;
body = null; body = null;
} }
xhr.open(method, url, true); xhr.open(method, url, true);

View File

@ -135,10 +135,10 @@ export default class uUtils {
* @returns {string} * @returns {string}
*/ */
static hexToRGBA(hex, opacity) { static hexToRGBA(hex, opacity) {
return 'rgba(' + (hex = hex.replace('#', '')) return `rgba(${(hex = hex.replace('#', ''))
.match(new RegExp('(.{' + hex.length / 3 + '})', 'g')) .match(new RegExp(`(.{${hex.length / 3}})`, 'g'))
.map((l) => parseInt(hex.length % 2 ? l + l : l, 16)) .map((l) => parseInt(hex.length % 2 ? l + l : l, 16))
.concat(opacity || 1).join(',') + ')'; .concat(opacity || 1).join(',')})`;
} }
/** /**