aboutsummaryrefslogtreecommitdiffstats
path: root/test/runner/browserstack/buildBrowserFromString.js
blob: 55aa38053b1716ca636dfdd9a61fcef191a53b65 (plain)
1
2
3
4
5
6
7
8
9
10
export function buildBrowserFromString( str ) {
	const [ browser, versionOrDevice, os, osVersion ] = str.split( "_" );

	// If the version starts with a colon, it's a device
	if ( versionOrDevice && versionOrDevice.startsWith( ":" ) ) {
		return { browser, device: versionOrDevice.slice( 1 ), os, os_version: osVersion };
	}

	return { browser, browser_version: versionOrDevice, os, os_version: osVersion };
}