From 264f2f422ba5f13e93010bab928acde5a9481809 Mon Sep 17 00:00:00 2001 From: Kasper Nilsson Date: Sun, 14 May 2017 17:52:14 -0700 Subject: [PATCH] ES6ify /scripts/util.js Bug: Issue 6179 Change-Id: Icc3a146dd50a9444b386212ff994203b2012e27b --- polygerrit-ui/app/scripts/util.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/polygerrit-ui/app/scripts/util.js b/polygerrit-ui/app/scripts/util.js index 6c83905ac5..07b543f694 100644 --- a/polygerrit-ui/app/scripts/util.js +++ b/polygerrit-ui/app/scripts/util.js @@ -14,7 +14,7 @@ (function(window) { 'use strict'; - var util = window.util || {}; + const util = window.util || {}; util.parseDate = function(dateStr) { // Timestamps are given in UTC and have the format @@ -25,14 +25,14 @@ }; util.getCookie = function(name) { - var key = name + '='; - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var c = cookies[i]; - while (c.charAt(0) == ' ') { + const key = name + '='; + const cookies = document.cookie.split(';'); + for (let i = 0; i < cookies.length; i++) { + let c = cookies[i]; + while (c.charAt(0) === ' ') { c = c.substring(1); } - if (c.indexOf(key) == 0) { + if (c.startsWith(key)) { return c.substring(key.length, c.length); } } @@ -50,7 +50,7 @@ * @return {String} Returns the truncated value of a URL. */ util.truncatePath = function(path) { - var pathPieces = path.split('/'); + const pathPieces = path.split('/'); if (pathPieces.length < 2) { return path;