From 88cfdb435c57c7bd762b446d89e53b2a430688c1 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 29 Nov 2016 10:55:04 +0100 Subject: [PATCH] Use indexOf instead of RegExp as suggested --- src/ol/color.js | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/src/ol/color.js b/src/ol/color.js index 1fc83c33c2..b9b040740a 100644 --- a/src/ol/color.js +++ b/src/ol/color.js @@ -13,24 +13,6 @@ goog.require('ol.math'); ol.color.HEX_COLOR_RE_ = /^#(?:[0-9a-f]{3}){1,2}$/i; -/** - * Regular expression for matching RGB style strings. - * @const - * @type {RegExp} - * @private - */ -ol.color.RGB_COLOR_RE_ = /^rgb\(/i; - - -/** - * Regular expression for matching RGBA style strings. - * @const - * @type {RegExp} - * @private - */ -ol.color.RGBA_COLOR_RE_ = /^rgba\(/; - - /** * Regular expression for matching potential named color style strings. * @const @@ -168,10 +150,10 @@ ol.color.fromStringInternal_ = function(s) { } a = 1; color = [r, g, b, a]; - } else if (ol.color.RGBA_COLOR_RE_.test(s)) { // rgba() + } else if (s.indexOf('rgba(') == 0) { // rgba() parts = s.slice(5, -1).split(',').map(Number); color = ol.color.normalize(parts); - } else if (ol.color.RGB_COLOR_RE_.test(s)) { // rgb() + } else if (s.indexOf('rgb(') == 0) { // rgb() parts = s.slice(4, -1).split(',').map(Number); parts.push(1); color = ol.color.normalize(parts);