UNPKG

siesta-lite

Version:

Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers

61 lines (44 loc) 1.46 kB
/* Siesta 5.6.1 Copyright(c) 2009-2022 Bryntum AB https://bryntum.com/contact https://bryntum.com/products/siesta/license */ Role('Siesta.Launcher.Options.Proxy', { override : { validate : function () { if (this.SUPER() === false) return false var options = this.options var proxy = options.proxy proxy && Joose.O.extend(options, this.parseProxyShortcut(proxy)) return true } }, methods : { parseProxyShortcut : function (str) { var res = {} var match = /(?:(.+?)(?:\:(.+))?@)?(.*)/.exec(str) if (match) { res[ 'proxy-user' ] = match[ 1 ] res[ 'proxy-password' ] = match[ 2 ] || null str = match[ 3 ] } var match = /(.+):(\d+)/.exec(str) if (match) { res[ 'proxy-host' ] = match[ 1 ] res[ 'proxy-port' ] = match[ 2 ] } else res[ 'proxy-host' ] = str return res }, getProxyHostPort : function () { var options = this.options var host = options[ 'proxy-host' ] var port = options[ 'proxy-port' ] if (host) return host + (port ? ':' + port : '') else return null } } })