1
0
mirror of https://github.com/lancedikson/bowser synced 2024-10-27 20:34:22 +00:00

updated the code to be more clear

This commit is contained in:
Ricardo Rauber Pereira 2019-04-23 10:11:04 +01:00
parent 42b0f185e2
commit 4d8c781369

View File

@ -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),