From 4d8c7813691104739fbf297865b0b098a35c4a71 Mon Sep 17 00:00:00 2001 From: Ricardo Rauber Pereira Date: Tue, 23 Apr 2019 10:11:04 +0100 Subject: [PATCH] updated the code to be more clear --- src/parser-browsers.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/parser-browsers.js b/src/parser-browsers.js index bc0c7f1..5c1a867 100644 --- a/src/parser-browsers.js +++ b/src/parser-browsers.js @@ -590,7 +590,11 @@ const browsersList = [ { test: [/.*/i], describe(ua) { - const regexp = ua.search('\\(') === -1 ? /^(.*)\/(.*) / : /^(.*)\/(.*)[ \t]\((.*)/; + // Define the regexp depending if the ua has device specifications + const regexpWithoutParenthesis = /^(.*)\/(.*) /; + const regexpWithParenthesis = /^(.*)\/(.*)[ \t]\((.*)/; + const hasDeviceSpec = ua.search('\\(') !== -1; + const regexp = hasDeviceSpec ? regexpWithoutParenthesis : regexpWithParenthesis; return { name: Utils.getFirstMatch(regexp, ua), version: Utils.getSecondMatch(regexp, ua),