Best JavaScript code snippet using cucumber-gherkin
AutoLoads.py
Source:AutoLoads.py
1import os2from poshc2.server.Config import ModulesDirectory, DatabaseType3if DatabaseType.lower() == "postgres":4 from poshc2.server.database.DBPostgres import update_mods, new_task, select_mods5else:6 from poshc2.server.database.DBSQLite import update_mods, new_task, select_mods7def check_module_loaded(module_name, randomuri, user, force=False):8 loadmodule_command = "loadmodule"9 try:10 modules_loaded = select_mods(randomuri)11 if force:12 for modname in os.listdir(ModulesDirectory):13 if modname.lower() == module_name.lower():14 module_name = modname15 new_task(f"{loadmodule_command} {module_name}", user, randomuri)16 update_mods(module_name, randomuri)17 if modules_loaded:18 new_modules_loaded = "%s %s" % (modules_loaded, module_name)19 if module_name not in modules_loaded:20 for modname in os.listdir(ModulesDirectory):21 if modname.lower() == module_name.lower():22 module_name = modname23 new_task(f"{loadmodule_command} {module_name}", user, randomuri)24 update_mods(new_modules_loaded, randomuri)25 else:26 new_modules_loaded = "%s" % (module_name)27 new_task(f"{loadmodule_command} {module_name}", user, randomuri)28 update_mods(new_modules_loaded, randomuri)29 except Exception as e:30 print(f"Error: {loadmodule_command} {module_name}: {e}")31def run_autoloads(command, randomuri, user):32 command = command.lower().strip()33 if command.startswith("invoke-eternalblue"): check_module_loaded("Exploit-EternalBlue.ps1", randomuri, user)34 elif command.startswith("invoke-psuacme"): check_module_loaded("Invoke-PsUACme.ps1", randomuri, user)35 elif command.startswith("invoke-bloodhound"): check_module_loaded("SharpHound.ps1", randomuri, user)36 elif command.startswith("brute-ad"): check_module_loaded("Brute-AD.ps1", randomuri, user)37 elif command.startswith("brute-locadmin"): check_module_loaded("Brute-LocAdmin.ps1", randomuri, user)38 elif command.startswith("bypass-uac"): check_module_loaded("Bypass-UAC.ps1", randomuri, user)39 elif command.startswith("cred-popper"): check_module_loaded("Cred-Popper.ps1", randomuri, user)40 elif command.startswith("cve-2016-9192"): check_module_loaded("CVE-2016-9192.ps1", randomuri, user)41 elif command.startswith("convertto-shellcode"): check_module_loaded("ConvertTo-Shellcode.ps1", randomuri, user)42 elif command.startswith("decrypt-rdcman"): check_module_loaded("Decrypt-RDCMan.ps1", randomuri, user)43 elif command.startswith("dump-ntds"): check_module_loaded("Dump-NTDS.ps1", randomuri, user)44 elif command.startswith("get-computerinfo"): check_module_loaded("Get-ComputerInfo.ps1", randomuri, user)45 elif command.startswith("get-creditcarddata"): check_module_loaded("Get-CreditCardData.ps1", randomuri, user)46 elif command.startswith("get-gppautologon"): check_module_loaded("Get-GPPAutologon.ps1", randomuri, user)47 elif command.startswith("get-gpppassword"): check_module_loaded("Get-GPPPassword.ps1", randomuri, user)48 elif command.startswith("get-idletime"): check_module_loaded("Get-IdleTime.ps1", randomuri, user)49 elif command.startswith("get-ipconfig"): check_module_loaded("Get-IPConfig.ps1", randomuri, user)50 elif command.startswith("get-keystrokes"): check_module_loaded("Get-Keystrokes.ps1", randomuri, user)51 elif command.startswith("get-hash"): check_module_loaded("Get-Hash.ps1", randomuri, user)52 elif command.startswith("get-locadm"): check_module_loaded("Get-LocAdm.ps1", randomuri, user)53 elif command.startswith("get-mshotfixes"): check_module_loaded("Get-MSHotFixes.ps1", randomuri, user)54 elif command.startswith("get-netstat"): check_module_loaded("Get-Netstat.ps1", randomuri, user)55 elif command.startswith("get-passnotexp"): check_module_loaded("Get-PassNotExp.ps1", randomuri, user)56 elif command.startswith("get-passpol"): check_module_loaded("Get-PassPol.ps1", randomuri, user)57 elif command.startswith("get-recentfiles"): check_module_loaded("Get-RecentFiles.ps1", randomuri, user)58 elif command.startswith("get-serviceperms"): check_module_loaded("Get-ServicePerms.ps1", randomuri, user)59 elif command.startswith("get-userinfo"): check_module_loaded("Get-UserInfo.ps1", randomuri, user)60 elif command.startswith("get-wlanpass"): check_module_loaded("Get-WLANPass.ps1", randomuri, user)61 elif command.startswith("invoke-pbind"): check_module_loaded("Invoke-Pbind.ps1", randomuri, user)62 elif command.startswith("get-domaingroupmember"): check_module_loaded("powerview.ps1", randomuri, user)63 elif command.startswith("invoke-kerberoast"): check_module_loaded("powerview.ps1", randomuri, user)64 elif command.startswith("resolve-ipaddress"): check_module_loaded("powerview.ps1", randomuri, user)65 elif command.startswith("invoke-userhunter"): check_module_loaded("powerview.ps1", randomuri, user)66 elif command.startswith("get-netlocalgroupmember"): check_module_loaded("powerview.ps1", randomuri, user)67 elif command.startswith("invoke-daisychain"): check_module_loaded("invoke-daisychain.ps1", randomuri, user)68 elif command.startswith("invoke-hostenum"): check_module_loaded("HostEnum.ps1", randomuri, user)69 elif command.startswith("inject-shellcode"): check_module_loaded("Inject-Shellcode.ps1", randomuri, user)70 elif command.startswith("inveigh-relay"): check_module_loaded("Inveigh-Relay.ps1", randomuri, user)71 elif command.startswith("inveigh"): check_module_loaded("Inveigh.ps1", randomuri, user)72 elif command.startswith("invoke-inveigh"): check_module_loaded("Inveigh.ps1", randomuri, user)73 elif command.startswith("invoke-arpscan"): check_module_loaded("Invoke-Arpscan.ps1", randomuri, user)74 elif command.startswith("arpscan"): check_module_loaded("Invoke-Arpscan.ps1", randomuri, user)75 elif command.startswith("invoke-dcsync"): check_module_loaded("Invoke-DCSync.ps1", randomuri, user)76 elif command.startswith("invoke-eventvwrbypass"): check_module_loaded("Invoke-EventVwrBypass.ps1", randomuri, user)77 elif command.startswith("invoke-hostscan"): check_module_loaded("Invoke-Hostscan.ps1", randomuri, user)78 elif command.startswith("invoke-ms16-032-proxy"): check_module_loaded("Invoke-MS16-032-Proxy.ps1", randomuri, user)79 elif command.startswith("invoke-ms16-032"): check_module_loaded("Invoke-MS16-032.ps1", randomuri, user)80 elif command.startswith("invoke-mimikatz"): check_module_loaded("Invoke-Mimikatz.ps1", randomuri, user)81 elif command.startswith("invoke-psinject"): check_module_loaded("Invoke-PSInject.ps1", randomuri, user)82 elif command.startswith("invoke-pipekat"): check_module_loaded("Invoke-Pipekat.ps1", randomuri, user)83 elif command.startswith("invoke-portscan"): check_module_loaded("Invoke-Portscan.ps1", randomuri, user)84 elif command.startswith("invoke-powerdump"): check_module_loaded("Invoke-PowerDump.ps1", randomuri, user)85 elif command.startswith("invoke-psexec"): check_module_loaded("Invoke-SMBExec.ps1", randomuri, user)86 elif command.startswith("invoke-reflectivepeinjection"): check_module_loaded("Invoke-ReflectivePEInjection.ps1", randomuri, user)87 elif command.startswith("invoke-reversednslookup"): check_module_loaded("Invoke-ReverseDnsLookup.ps1", randomuri, user)88 elif command.startswith("invoke-runas"): check_module_loaded("Invoke-RunAs.ps1", randomuri, user)89 elif command.startswith("runas-netonly"): check_module_loaded("RunAs-NetOnly.ps1", randomuri, user)90 elif command.startswith("invoke-smblogin"): check_module_loaded("Invoke-SMBExec.ps1", randomuri, user)91 elif command.startswith("invoke-smbclient"): check_module_loaded("Invoke-SMBClient.ps1", randomuri, user)92 elif command.startswith("invoke-smbexec"): check_module_loaded("Invoke-SMBExec.ps1", randomuri, user)93 elif command.startswith("invoke-psexec"): check_module_loaded("Invoke-SMBExec.ps1", randomuri, user)94 elif command.startswith("invoke-shellcode"): check_module_loaded("Invoke-Shellcode.ps1", randomuri, user)95 elif command.startswith("invoke-sniffer"): check_module_loaded("Invoke-Sniffer.ps1", randomuri, user)96 elif command.startswith("invoke-sqlquery"): check_module_loaded("Invoke-SqlQuery.ps1", randomuri, user)97 elif command.startswith("invoke-tater"): check_module_loaded("Invoke-Tater.ps1", randomuri, user)98 elif command.startswith("invoke-thehash"): check_module_loaded("Invoke-TheHash.ps1", randomuri, user)99 elif command.startswith("invoke-tokenmanipulation"): check_module_loaded("Invoke-TokenManipulation.ps1", randomuri, user)100 elif command.startswith("invoke-wmichecker"): check_module_loaded("Invoke-WMIChecker.ps1", randomuri, user)101 elif command.startswith("invoke-wmicommand"): check_module_loaded("Invoke-WMICommand.ps1", randomuri, user)102 elif command.startswith("invoke-wscriptbypassuac"): check_module_loaded("Invoke-WScriptBypassUAC.ps1", randomuri, user)103 elif command.startswith("invoke-winrmsession"): check_module_loaded("Invoke-WinRMSession.ps1", randomuri, user)104 elif command.startswith("out-minidump"): check_module_loaded("Out-Minidump.ps1", randomuri, user)105 elif command.startswith("portscan"): check_module_loaded("PortScanner.ps1", randomuri, user)106 elif command.startswith("powercat"): check_module_loaded("powercat.ps1", randomuri, user)107 elif command.startswith("invoke-allchecks"): check_module_loaded("PowerUp.ps1", randomuri, user)108 elif command.startswith("set-lhstokenprivilege"): check_module_loaded("Set-LHSTokenPrivilege.ps1", randomuri, user)109 elif command.startswith("sharpsocks"): check_module_loaded("SharpSocks.ps1", randomuri, user)110 elif command.startswith("find-allvulns"): check_module_loaded("Sherlock.ps1", randomuri, user)111 elif command.startswith("test-adcredential"): check_module_loaded("Test-ADCredential.ps1", randomuri, user)112 elif command.startswith("new-zipfile"): check_module_loaded("Zippy.ps1", randomuri, user)113 elif command.startswith("get-netuser"): check_module_loaded("powerview.ps1", randomuri, user)114 elif command.startswith("invoke-aclscanner"): check_module_loaded("powerview.ps1", randomuri, user)115 elif command.startswith("get-dfsshare"): check_module_loaded("powerview.ps1", randomuri, user)116 elif command.startswith("get-objectacl"): check_module_loaded("powerview.ps1", randomuri, user)117 elif command.startswith("add-objectacl"): check_module_loaded("powerview.ps1", randomuri, user)118 elif command.startswith("get-netuser"): check_module_loaded("powerview.ps1", randomuri, user)119 elif command.startswith("get-domainuser"): check_module_loaded("powerview.ps1", randomuri, user)120 elif command.startswith("get-netcomputer"): check_module_loaded("powerview.ps1", randomuri, user)121 elif command.startswith("get-domaincomputer"): check_module_loaded("powerview.ps1", randomuri, user)122 elif command.startswith("get-netuser"): check_module_loaded("powerview.ps1", randomuri, user)123 elif command.startswith("get-netgroup"): check_module_loaded("powerview.ps1", randomuri, user)124 elif command.startswith("get-netgroupmember"): check_module_loaded("powerview.ps1", randomuri, user)125 elif command.startswith("get-netshare"): check_module_loaded("powerview.ps1", randomuri, user)126 elif command.startswith("invoke-sharefinder"): check_module_loaded("powerview.ps1", randomuri, user)127 elif command.startswith("get-netdomain"): check_module_loaded("powerview.ps1", randomuri, user)128 elif command.startswith("get-netdomaincontroller"): check_module_loaded("powerview.ps1", randomuri, user)129 elif command.startswith("get-netforest"): check_module_loaded("powerview.ps1", randomuri, user)130 elif command.startswith("find-domainshare"): check_module_loaded("powerview.ps1", randomuri, user)131 elif command.startswith("get-netforestdomain"): check_module_loaded("powerview.ps1", randomuri, user)132 elif command.startswith("invoke-mapdomaintrust"): check_module_loaded("powerview.ps1", randomuri, user)133 elif command.startswith("get-wmireglastloggedon"): check_module_loaded("powerview.ps1", randomuri, user)134 elif command.startswith("get-wmiregcachedrdpconnection"): check_module_loaded("powerview.ps1", randomuri, user)135 elif command.startswith("get-wmiregmounteddrive"): check_module_loaded("powerview.ps1", randomuri, user)136 elif command.startswith("invoke-wmievent"): check_module_loaded("Invoke-WMIEvent.ps1", randomuri, user)137 elif command.startswith("remove-wmievent"): check_module_loaded("Invoke-WMIEvent.ps1", randomuri, user)138 elif command.startswith("invoke-wmi"): check_module_loaded("Invoke-WMIExec.ps1", randomuri, user)139 elif command.startswith("get-lapspasswords"): check_module_loaded("Get-LAPSPasswords.ps1", randomuri, user)140 elif command.startswith("new-jscriptshell"): check_module_loaded("New-JScriptShell.ps1", randomuri, user)141 elif command.startswith("invoke-edrchecker"): check_module_loaded("Invoke-EDRChecker.ps1", randomuri, user)142def run_autoloads_sharp(command, randomuri, user):143 command = command.lower().strip()144 if command.startswith("run-exe seatbelt"): check_module_loaded("Seatbelt.exe", randomuri, user)145 elif command.startswith("run-exe smbexec.program"): check_module_loaded("SExec.exe", randomuri, user)146 elif command.startswith("run-exe sharpup"): check_module_loaded("SharpUp.exe", randomuri, user)147 elif command.startswith("run-exe safetydump"): check_module_loaded("SafetyDump.exe", randomuri, user)148 elif command.startswith("run-exe rubeus"): check_module_loaded("Rubeus.exe", randomuri, user)149 elif command.startswith("run-exe sharpview"): check_module_loaded("SharpView.exe", randomuri, user)150 elif command.startswith("run-exe watson"): check_module_loaded("Watson.exe", randomuri, user)151 elif command.startswith("run-exe sharphound"): check_module_loaded("SharpHound.exe", randomuri, user)152 elif command.startswith("run-exe internalmonologue"): check_module_loaded("InternalMonologue.exe", randomuri, user)153 elif command.startswith("run-exe sharpsocks"): check_module_loaded("SharpSocks.exe", randomuri, user)154 elif command.startswith("run-exe sharpweb"): check_module_loaded("SharpWeb.exe", randomuri, user)155 elif command.startswith("run-exe sharpwmi"): check_module_loaded("SharpWMI.exe", randomuri, user)156 elif command.startswith("run-exe wmiexec.program"): check_module_loaded("WExec.exe", randomuri, user)157 elif command.startswith("run-exe smbexec.program"): check_module_loaded("SExec.exe", randomuri, user)158 elif command.startswith("run-exe invoke_dcom.program"): check_module_loaded("DCOM.exe", randomuri, user)159 elif command.startswith("run-exe sharpsc.program"): check_module_loaded("SharpSC.exe", randomuri, user)160 elif command.startswith("get-screenshotallwindows"): check_module_loaded("Screenshot.dll", randomuri, user)161 elif command.startswith("run-exe sharpcookiemonster.program"): check_module_loaded("SharpCookieMonster.exe", randomuri, user)162 elif command.startswith("sharpsocks"): check_module_loaded("SharpSocks.exe", randomuri, user)163 elif command.startswith("safetykatz"): check_module_loaded("SafetyKatz.exe", randomuri, user)164 elif command.startswith("sharpwmi"): check_module_loaded("SharpWMI.exe", randomuri, user)165 elif command.startswith("sharpsc"): check_module_loaded("SharpSC.exe", randomuri, user)166 elif command.startswith("sharpcookiemonster"): check_module_loaded("SharpCookieMonster.exe", randomuri, user)167 elif command.startswith("run-exe program ps"): check_module_loaded("PS.exe", randomuri, user)168 elif command.startswith("pslo"): check_module_loaded("PS.exe", randomuri, user)169 elif command.startswith("run-dll sharpsploit"): check_module_loaded("SharpSploit.dll", randomuri, user)170 elif command.startswith("run-exe mainclass runascs"): check_module_loaded("RunasCs.exe", randomuri, user)171 elif command.startswith("invoke-daisychain"): check_module_loaded("Daisy.dll", randomuri, user)172 elif command.startswith("run-exe runas.program runas"): check_module_loaded("RunAs.exe", randomuri, user)173 elif command.startswith("portscan"): check_module_loaded("PortScanner.dll", randomuri, user)174 elif command.startswith("run-exe sweetpotato.program "): check_module_loaded("SweetPotato.exe", randomuri, user)175 elif command.startswith("run-exe sharpdpapi.program "): check_module_loaded("SharpDPAPI.exe", randomuri, user)...
string-startswith.js
Source:string-startswith.js
...23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.27assertFalse("abc".startsWith("a", Infinity));28assertEquals(1, String.prototype.startsWith.length);29var testString = "Hello World";30assertTrue(testString.startsWith(""));31assertTrue(testString.startsWith("Hello"));32assertFalse(testString.startsWith("hello"));33assertFalse(testString.startsWith("Hello World!"));34assertFalse(testString.startsWith(null));35assertFalse(testString.startsWith(undefined));36assertFalse(testString.startsWith());37assertTrue("null".startsWith(null));38assertTrue("undefined".startsWith(undefined));39var georgianUnicodeString = "\u10D0\u10D1\u10D2\u10D3\u10D4\u10D5\u10D6\u10D7";40assertTrue(georgianUnicodeString.startsWith(georgianUnicodeString));41assertTrue(georgianUnicodeString.startsWith("\u10D0\u10D1\u10D2"));42assertFalse(georgianUnicodeString.startsWith("\u10D8"));43assertThrows("String.prototype.startsWith.call(null, 'test')", TypeError);44assertThrows("String.prototype.startsWith.call(null, null)", TypeError);45assertThrows("String.prototype.startsWith.call(undefined, undefined)", TypeError);46assertThrows("String.prototype.startsWith.apply(null, ['test'])", TypeError);47assertThrows("String.prototype.startsWith.apply(null, [null])", TypeError);48assertThrows("String.prototype.startsWith.apply(undefined, [undefined])", TypeError);49var TEST_INPUT = [{50 msg: "Empty string", val: ""51}, {52 msg: "Number 1234.34", val: 1234.3453}, {54 msg: "Integer number 0", val: 055}, {56 msg: "Negative number -1", val: -157}, {58 msg: "Boolean true", val: true59}, {60 msg: "Boolean false", val: false61}, {62 msg: "Empty array []", val: []63}, {64 msg: "Empty object {}", val: {}65}, {66 msg: "Array of size 3", val: new Array(3)67}];68function testNonStringValues() {69 var i = 0;70 var l = TEST_INPUT.length;71 for (; i < l; i++) {72 var e = TEST_INPUT[i];73 var v = e.val;74 var s = String(v);75 assertTrue(s.startsWith(v), e.msg);76 assertTrue(String.prototype.startsWith.call(v, v), e.msg);77 assertTrue(String.prototype.startsWith.apply(v, [v]), e.msg);78 }79}80testNonStringValues();81var CustomType = function(value) {82 this.startsWith = String.prototype.startsWith;83 this.toString = function() {84 return String(value);85 }86};87function testCutomType() {88 var i = 0;89 var l = TEST_INPUT.length;90 for (; i < l; i++) {91 var e = TEST_INPUT[i];92 var v = e.val;93 var o = new CustomType(v);94 assertTrue(o.startsWith(v), e.msg);95 }96}97testCutomType();98// Test cases found in FF99assertTrue("abc".startsWith("abc"));100assertTrue("abcd".startsWith("abc"));101assertTrue("abc".startsWith("a"));102assertFalse("abc".startsWith("abcd"));103assertFalse("abc".startsWith("bcde"));104assertFalse("abc".startsWith("b"));105assertTrue("abc".startsWith("abc", 0));106assertFalse("abc".startsWith("bc", 0));107assertTrue("abc".startsWith("bc", 1));108assertFalse("abc".startsWith("c", 1));109assertFalse("abc".startsWith("abc", 1));110assertTrue("abc".startsWith("c", 2));111assertFalse("abc".startsWith("d", 2));112assertFalse("abc".startsWith("dcd", 2));113assertFalse("abc".startsWith("a", 42));114assertFalse("abc".startsWith("a", Infinity));115assertTrue("abc".startsWith("a", NaN));116assertFalse("abc".startsWith("b", NaN));117assertTrue("abc".startsWith("ab", -43));118assertTrue("abc".startsWith("ab", -Infinity));119assertFalse("abc".startsWith("bc", -42));120assertFalse("abc".startsWith("bc", -Infinity));121// Test cases taken from122// https://github.com/mathiasbynens/String.prototype.startsWith/blob/master/tests/tests.js123Object.prototype[1] = 2; // try to break `arguments[1]`124assertEquals(String.prototype.startsWith.length, 1);125assertEquals(String.prototype.propertyIsEnumerable("startsWith"), false);126assertEquals("undefined".startsWith(), true);127assertEquals("undefined".startsWith(undefined), true);128assertEquals("undefined".startsWith(null), false);129assertEquals("null".startsWith(), false);130assertEquals("null".startsWith(undefined), false);131assertEquals("null".startsWith(null), true);132assertEquals("abc".startsWith(), false);133assertEquals("abc".startsWith(""), true);134assertEquals("abc".startsWith("\0"), false);135assertEquals("abc".startsWith("a"), true);136assertEquals("abc".startsWith("b"), false);137assertEquals("abc".startsWith("ab"), true);138assertEquals("abc".startsWith("bc"), false);139assertEquals("abc".startsWith("abc"), true);140assertEquals("abc".startsWith("bcd"), false);141assertEquals("abc".startsWith("abcd"), false);142assertEquals("abc".startsWith("bcde"), false);143assertEquals("abc".startsWith("", NaN), true);144assertEquals("abc".startsWith("\0", NaN), false);145assertEquals("abc".startsWith("a", NaN), true);146assertEquals("abc".startsWith("b", NaN), false);147assertEquals("abc".startsWith("ab", NaN), true);148assertEquals("abc".startsWith("bc", NaN), false);149assertEquals("abc".startsWith("abc", NaN), true);150assertEquals("abc".startsWith("bcd", NaN), false);151assertEquals("abc".startsWith("abcd", NaN), false);152assertEquals("abc".startsWith("bcde", NaN), false);153assertEquals("abc".startsWith("", false), true);154assertEquals("abc".startsWith("\0", false), false);155assertEquals("abc".startsWith("a", false), true);156assertEquals("abc".startsWith("b", false), false);157assertEquals("abc".startsWith("ab", false), true);158assertEquals("abc".startsWith("bc", false), false);159assertEquals("abc".startsWith("abc", false), true);160assertEquals("abc".startsWith("bcd", false), false);161assertEquals("abc".startsWith("abcd", false), false);162assertEquals("abc".startsWith("bcde", false), false);163assertEquals("abc".startsWith("", undefined), true);164assertEquals("abc".startsWith("\0", undefined), false);165assertEquals("abc".startsWith("a", undefined), true);166assertEquals("abc".startsWith("b", undefined), false);167assertEquals("abc".startsWith("ab", undefined), true);168assertEquals("abc".startsWith("bc", undefined), false);169assertEquals("abc".startsWith("abc", undefined), true);170assertEquals("abc".startsWith("bcd", undefined), false);171assertEquals("abc".startsWith("abcd", undefined), false);172assertEquals("abc".startsWith("bcde", undefined), false);173assertEquals("abc".startsWith("", null), true);174assertEquals("abc".startsWith("\0", null), false);175assertEquals("abc".startsWith("a", null), true);176assertEquals("abc".startsWith("b", null), false);177assertEquals("abc".startsWith("ab", null), true);178assertEquals("abc".startsWith("bc", null), false);179assertEquals("abc".startsWith("abc", null), true);180assertEquals("abc".startsWith("bcd", null), false);181assertEquals("abc".startsWith("abcd", null), false);182assertEquals("abc".startsWith("bcde", null), false);183assertEquals("abc".startsWith("", -Infinity), true);184assertEquals("abc".startsWith("\0", -Infinity), false);185assertEquals("abc".startsWith("a", -Infinity), true);186assertEquals("abc".startsWith("b", -Infinity), false);187assertEquals("abc".startsWith("ab", -Infinity), true);188assertEquals("abc".startsWith("bc", -Infinity), false);189assertEquals("abc".startsWith("abc", -Infinity), true);190assertEquals("abc".startsWith("bcd", -Infinity), false);191assertEquals("abc".startsWith("abcd", -Infinity), false);192assertEquals("abc".startsWith("bcde", -Infinity), false);193assertEquals("abc".startsWith("", -1), true);194assertEquals("abc".startsWith("\0", -1), false);195assertEquals("abc".startsWith("a", -1), true);196assertEquals("abc".startsWith("b", -1), false);197assertEquals("abc".startsWith("ab", -1), true);198assertEquals("abc".startsWith("bc", -1), false);199assertEquals("abc".startsWith("abc", -1), true);200assertEquals("abc".startsWith("bcd", -1), false);201assertEquals("abc".startsWith("abcd", -1), false);202assertEquals("abc".startsWith("bcde", -1), false);203assertEquals("abc".startsWith("", -0), true);204assertEquals("abc".startsWith("\0", -0), false);205assertEquals("abc".startsWith("a", -0), true);206assertEquals("abc".startsWith("b", -0), false);207assertEquals("abc".startsWith("ab", -0), true);208assertEquals("abc".startsWith("bc", -0), false);209assertEquals("abc".startsWith("abc", -0), true);210assertEquals("abc".startsWith("bcd", -0), false);211assertEquals("abc".startsWith("abcd", -0), false);212assertEquals("abc".startsWith("bcde", -0), false);213assertEquals("abc".startsWith("", +0), true);214assertEquals("abc".startsWith("\0", +0), false);215assertEquals("abc".startsWith("a", +0), true);216assertEquals("abc".startsWith("b", +0), false);217assertEquals("abc".startsWith("ab", +0), true);218assertEquals("abc".startsWith("bc", +0), false);219assertEquals("abc".startsWith("abc", +0), true);220assertEquals("abc".startsWith("bcd", +0), false);221assertEquals("abc".startsWith("abcd", +0), false);222assertEquals("abc".startsWith("bcde", +0), false);223assertEquals("abc".startsWith("", 1), true);224assertEquals("abc".startsWith("\0", 1), false);225assertEquals("abc".startsWith("a", 1), false);226assertEquals("abc".startsWith("b", 1), true);227assertEquals("abc".startsWith("ab", 1), false);228assertEquals("abc".startsWith("bc", 1), true);229assertEquals("abc".startsWith("abc", 1), false);230assertEquals("abc".startsWith("bcd", 1), false);231assertEquals("abc".startsWith("abcd", 1), false);232assertEquals("abc".startsWith("bcde", 1), false);233assertEquals("abc".startsWith("", +Infinity), true);234assertEquals("abc".startsWith("\0", +Infinity), false);235assertEquals("abc".startsWith("a", +Infinity), false);236assertEquals("abc".startsWith("b", +Infinity), false);237assertEquals("abc".startsWith("ab", +Infinity), false);238assertEquals("abc".startsWith("bc", +Infinity), false);239assertEquals("abc".startsWith("abc", +Infinity), false);240assertEquals("abc".startsWith("bcd", +Infinity), false);241assertEquals("abc".startsWith("abcd", +Infinity), false);242assertEquals("abc".startsWith("bcde", +Infinity), false);243assertEquals("abc".startsWith("", true), true);244assertEquals("abc".startsWith("\0", true), false);245assertEquals("abc".startsWith("a", true), false);246assertEquals("abc".startsWith("b", true), true);247assertEquals("abc".startsWith("ab", true), false);248assertEquals("abc".startsWith("bc", true), true);249assertEquals("abc".startsWith("abc", true), false);250assertEquals("abc".startsWith("bcd", true), false);251assertEquals("abc".startsWith("abcd", true), false);252assertEquals("abc".startsWith("bcde", true), false);253assertEquals("abc".startsWith("", "x"), true);254assertEquals("abc".startsWith("\0", "x"), false);255assertEquals("abc".startsWith("a", "x"), true);256assertEquals("abc".startsWith("b", "x"), false);257assertEquals("abc".startsWith("ab", "x"), true);258assertEquals("abc".startsWith("bc", "x"), false);259assertEquals("abc".startsWith("abc", "x"), true);260assertEquals("abc".startsWith("bcd", "x"), false);261assertEquals("abc".startsWith("abcd", "x"), false);262assertEquals("abc".startsWith("bcde", "x"), false);263assertEquals("[a-z]+(bar)?".startsWith("[a-z]+"), true);264assertThrows(function() { "[a-z]+(bar)?".startsWith(/[a-z]+/); }, TypeError);265assertEquals("[a-z]+(bar)?".startsWith("(bar)?", 6), true);266assertThrows(function() { "[a-z]+(bar)?".startsWith(/(bar)?/); }, TypeError);267assertThrows(function() { "[a-z]+/(bar)?/".startsWith(/(bar)?/); }, TypeError);268// http://mathiasbynens.be/notes/javascript-unicode#poo-test269var string = "I\xF1t\xEBrn\xE2ti\xF4n\xE0liz\xE6ti\xF8n\u2603\uD83D\uDCA9";270assertEquals(string.startsWith(""), true);271assertEquals(string.startsWith("\xF1t\xEBr"), false);272assertEquals(string.startsWith("\xF1t\xEBr", 1), true);273assertEquals(string.startsWith("\xE0liz\xE6"), false);274assertEquals(string.startsWith("\xE0liz\xE6", 11), true);275assertEquals(string.startsWith("\xF8n\u2603\uD83D\uDCA9"), false);276assertEquals(string.startsWith("\xF8n\u2603\uD83D\uDCA9", 18), true);277assertEquals(string.startsWith("\u2603"), false);278assertEquals(string.startsWith("\u2603", 20), true);279assertEquals(string.startsWith("\uD83D\uDCA9"), false);280assertEquals(string.startsWith("\uD83D\uDCA9", 21), true);281assertThrows(function() {282 String.prototype.startsWith.call(undefined);283}, TypeError);284assertThrows(function() {285 String.prototype.startsWith.call(undefined, "b");286}, TypeError);287assertThrows(function() {288 String.prototype.startsWith.call(undefined, "b", 4);289}, TypeError);290assertThrows(function() {291 String.prototype.startsWith.call(null);292}, TypeError);293assertThrows(function() {294 String.prototype.startsWith.call(null, "b");295}, TypeError);296assertThrows(function() {297 String.prototype.startsWith.call(null, "b", 4);298}, TypeError);299assertEquals(String.prototype.startsWith.call(42, "2"), false);300assertEquals(String.prototype.startsWith.call(42, "4"), true);301assertEquals(String.prototype.startsWith.call(42, "b", 4), false);302assertEquals(String.prototype.startsWith.call(42, "2", 1), true);303assertEquals(String.prototype.startsWith.call(42, "2", 4), false);304assertEquals(String.prototype.startsWith.call({305 "toString": function() { return "abc"; }306}, "b", 0), false);307assertEquals(String.prototype.startsWith.call({308 "toString": function() { return "abc"; }309}, "b", 1), true);310assertEquals(String.prototype.startsWith.call({311 "toString": function() { return "abc"; }312}, "b", 2), false);313assertThrows(function() {314 String.prototype.startsWith.call({315 "toString": function() { throw RangeError(); }316 }, /./);317}, RangeError);318assertThrows(function() {319 String.prototype.startsWith.call({320 "toString": function() { return "abc"; }321 }, /./);322}, TypeError);323assertThrows(function() {324 String.prototype.startsWith.apply(undefined);325}, TypeError);326assertThrows(function() {327 String.prototype.startsWith.apply(undefined, ["b"]);328}, TypeError);329assertThrows(function() {330 String.prototype.startsWith.apply(undefined, ["b", 4]);331}, TypeError);332assertThrows(function() {333 String.prototype.startsWith.apply(null);334}, TypeError);335assertThrows(function() {336 String.prototype.startsWith.apply(null, ["b"]);337}, TypeError);338assertThrows(function() {339 String.prototype.startsWith.apply(null, ["b", 4]);340}, TypeError);341assertEquals(String.prototype.startsWith.apply(42, ["2"]), false);342assertEquals(String.prototype.startsWith.apply(42, ["4"]), true);343assertEquals(String.prototype.startsWith.apply(42, ["b", 4]), false);344assertEquals(String.prototype.startsWith.apply(42, ["2", 1]), true);345assertEquals(String.prototype.startsWith.apply(42, ["2", 4]), false);346assertEquals(String.prototype.startsWith.apply({347 "toString": function() {348 return "abc";349 }350}, ["b", 0]), false);351assertEquals(String.prototype.startsWith.apply({352 "toString": function() {353 return "abc";354 }355}, ["b", 1]), true);356assertEquals(String.prototype.startsWith.apply({357 "toString": function() {358 return "abc";359 }360}, ["b", 2]), false);361assertThrows(function() {362 String.prototype.startsWith.apply({363 "toString": function() { throw RangeError(); }364 }, [/./]);365}, RangeError);366assertThrows(function() {367 String.prototype.startsWith.apply({368 "toString": function() { return "abc"; }369 }, [/./]);370}, TypeError);371// startsWith does its brand checks with Symbol.match372var re = /./;373assertThrows(function() {374 "".startsWith(re);375}, TypeError);376re[Symbol.match] = false;...
take_snapshot.py
Source:take_snapshot.py
1#!/usr/bin/env python2#############################################################################3#4# Copyright (C) 2015 The Qt Company Ltd.5# Contact: http://www.qt.io/licensing/6#7# This file is part of the QtWebEngine module of the Qt Toolkit.8#9# $QT_BEGIN_LICENSE:LGPL$10# Commercial License Usage11# Licensees holding valid commercial Qt licenses may use this file in12# accordance with the commercial license agreement provided with the13# Software or, alternatively, in accordance with the terms contained in14# a written agreement between you and The Qt Company. For licensing terms15# and conditions see http://www.qt.io/terms-conditions. For further16# information use the contact form at http://www.qt.io/contact-us.17#18# GNU Lesser General Public License Usage19# Alternatively, this file may be used under the terms of the GNU Lesser20# General Public License version 2.1 as published by the Free Software21# Foundation and appearing in the file LICENSE.LGPL included in the22# packaging of this file. Please review the following information to23# ensure the GNU Lesser General Public License version 2.1 requirements24# will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.25#26# As a special exception, The Qt Company gives you certain additional27# rights. These rights are described in The Qt Company LGPL Exception28# version 1.1, included in the file LGPL_EXCEPTION.txt in this package.29#30# GNU General Public License Usage31# Alternatively, this file may be used under the terms of the GNU32# General Public License version 3.0 as published by the Free Software33# Foundation and appearing in the file LICENSE.GPL included in the34# packaging of this file. Please review the following information to35# ensure the GNU General Public License version 3.0 requirements will be36# met: http://www.gnu.org/copyleft/gpl.html.37#38#39# $QT_END_LICENSE$40#41#############################################################################42import glob43import os44import subprocess45import sys46import imp47import errno48import shutil49from distutils.version import StrictVersion50import git_submodule as GitSubmodule51qtwebengine_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))52os.chdir(qtwebengine_root)53def isInGitBlacklist(file_path):54 # We do need all the gyp files.55 if file_path.endswith('.gyp') or file_path.endswith('.gypi') or file_path.endswith('.isolate'):56 False57 if ( '.gitignore' in file_path58 or '.gitmodules' in file_path59 or '.gitattributes' in file_path60 or '.DEPS' in file_path ):61 return True62def isInChromiumBlacklist(file_path):63 # Filter out empty submodule directories.64 if (os.path.isdir(file_path)):65 return True66 # We do need all the gyp files.67 if file_path.endswith('.gyp') or file_path.endswith('.gypi') or file_path.endswith('.isolate'):68 return False69 if ( '_jni' in file_path70 or 'jni_' in file_path71 or 'testdata/' in file_path72 or file_path.startswith('third_party/android_tools')73 or '/tests/' in file_path74 or ('/test/' in file_path and75 not '/webrtc/' in file_path and76 not file_path.startswith('net/test/') and77 not file_path.endswith('mock_chrome_application_mac.h') and78 not file_path.endswith('perftimer.h') and79 not 'ozone' in file_path)80 or file_path.endswith('.java')81 or file_path.startswith('android_webview')82 or file_path.startswith('apps/')83 or file_path.startswith('ash/')84 or file_path.startswith('athena')85 or file_path.startswith('base/android/java')86 or file_path.startswith('breakpad')87 or file_path.startswith('build/android/')88 or (file_path.startswith('chrome/') and89 not file_path.startswith('chrome/VERSION') and90 not '/app/theme/' in file_path and91 not '/app/resources/' in file_path and92 not '/browser/resources/' in file_path and93 not '/renderer/resources/' in file_path and94 not 'repack_locales' in file_path and95 not 'third_party/chromevox' in file_path and96 not 'media/desktop_media_list.h' in file_path and97 not 'media/desktop_streams_registry.' in file_path and98 not 'common/chrome_switches.' in file_path and99 not 'common/localized_error.' in file_path and100 not file_path.endswith('cf_resources.rc') and101 not file_path.endswith('version.py') and102 not file_path.endswith('.grd') and103 not file_path.endswith('.grdp') and104 not file_path.endswith('.json') and105 not file_path.endswith('chrome_version.rc.version'))106 or file_path.startswith('chrome_frame')107 or file_path.startswith('chromeos')108 or file_path.startswith('cloud_print')109 or (file_path.startswith('components') and110 not file_path.startswith('components/device_event_log') and111 not file_path.startswith('components/devtools_') and112 not file_path.startswith('components/error_page') and113 not file_path.startswith('components/mime_util') and114 not file_path.startswith('components/printing') and115 not file_path.startswith('components/resources') and116 not file_path.startswith('components/scheduler') and117 not file_path.startswith('components/strings') and118 not file_path.startswith('components/tracing') and119 not file_path.startswith('components/visitedlink') and120 not file_path.startswith('components/web_cache') and121 not file_path.startswith('components/webcrypto') and122 not file_path.endswith('.grdp') and123 not 'components_strings' in file_path)124 or file_path.startswith('content/public/android/java')125 or (file_path.startswith('content/shell') and126 not file_path.startswith('content/shell/common'))127 or file_path.startswith('courgette')128 or (file_path.startswith('extensions') and129 not 'browser/extension_function_registry.h' in file_path and130 not 'browser/extension_function_histogram_value.h' in file_path)131 or file_path.startswith('google_update')132 or file_path.startswith('ios')133 or file_path.startswith('media/base/android/java')134 or file_path.startswith('native_client')135 or file_path.startswith('net/android/java')136 or file_path.startswith('pdf')137 or file_path.startswith('remoting')138 or file_path.startswith('rlz')139 or file_path.startswith('sync')140 or file_path.startswith('testing/android')141 or file_path.startswith('testing/buildbot')142 or file_path.startswith('third_party/WebKit/LayoutTests')143 or file_path.startswith('third_party/WebKit/ManualTests')144 or file_path.startswith('third_party/WebKit/PerformanceTests')145 or file_path.startswith('third_party/accessibility-audit')146 or file_path.startswith('third_party/android_')147 or file_path.startswith('third_party/apache-win32')148 or file_path.startswith('third_party/apple_sample_code')149 or file_path.startswith('third_party/ashmem')150 or file_path.startswith('third_party/binutils')151 or file_path.startswith('third_party/bison')152 or (file_path.startswith('third_party/cacheinvalidation') and153 not file_path.endswith('isolate'))154 or file_path.startswith('third_party/chromite')155 or file_path.startswith('third_party/cld_2')156 or file_path.startswith('third_party/codesighs')157 or file_path.startswith('third_party/colorama')158 or file_path.startswith('third_party/cros_system_api')159 or file_path.startswith('third_party/cygwin')160 or file_path.startswith('third_party/cython')161 or file_path.startswith('third_party/deqp')162 or file_path.startswith('third_party/elfutils')163 or file_path.startswith('third_party/google_input_tools')164 or file_path.startswith('third_party/gperf')165 or file_path.startswith('third_party/gnu_binutils')166 or file_path.startswith('third_party/gtk+')167 or file_path.startswith('third_party/google_appengine_cloudstorage')168 or file_path.startswith('third_party/google_toolbox_for_mac')169 or file_path.startswith('third_party/hunspell_dictionaries')170 or file_path.startswith('third_party/hunspell')171 or file_path.startswith('third_party/instrumented_libraries')172 or file_path.startswith('third_party/jsr-305/src')173 or file_path.startswith('third_party/junit')174 or file_path.startswith('third_party/libphonenumber')175 or file_path.startswith('third_party/libaddressinput')176 or file_path.startswith('third_party/libc++')177 or file_path.startswith('third_party/libc++abi')178 or file_path.startswith('third_party/liblouis')179 or file_path.startswith('third_party/lighttpd')180 or file_path.startswith('third_party/markdown')181 or file_path.startswith('third_party/mingw-w64')182 or file_path.startswith('third_party/nacl_sdk_binaries')183 or (file_path.startswith('third_party/polymer') and184 not file_path.startswith('third_party/polymer/v1_0/components-chromium/'))185 or file_path.startswith('third_party/pdfsqueeze')186 or file_path.startswith('third_party/pefile')187 or file_path.startswith('third_party/perl')188 or file_path.startswith('third_party/pdfium')189 or file_path.startswith('third_party/psyco_win32')190 or file_path.startswith('third_party/scons-2.0.1')191 or file_path.startswith('third_party/trace-viewer')192 or file_path.startswith('third_party/undoview')193 or file_path.startswith('third_party/webgl')194 or (file_path.startswith('tools') and195 not file_path.startswith('tools/clang') and196 not file_path.startswith('tools/compile_test') and197 not file_path.startswith('tools/generate_library_loader') and198 not file_path.startswith('tools/generate_shim_headers') and199 not file_path.startswith('tools/generate_stubs') and200 not file_path.startswith('tools/grit') and201 not file_path.startswith('tools/gyp') and202 not file_path.startswith('tools/json_comment_eater') and203 not file_path.startswith('tools/json_schema_compiler') and204 not file_path.startswith('tools/idl_parser') and205 not file_path.startswith('tools/protoc_wrapper'))206 or file_path.startswith('ui/android/java')207 or file_path.startswith('ui/app_list')208 or file_path.startswith('ui/base/ime/chromeos')209 or file_path.startswith('ui/chromeos')210 or file_path.startswith('ui/display/chromeos')211 or file_path.startswith('ui/events/ozone/chromeos')212 or file_path.startswith('ui/file_manager')213 or file_path.startswith('ui/gfx/chromeos')214 ):215 return True216 return False217def printProgress(current, total):218 sys.stdout.write("\r{} of {}".format(current, total))219 sys.stdout.flush()220def copyFile(src, dst):221 src = os.path.abspath(src)222 dst = os.path.abspath(dst)223 dst_dir = os.path.dirname(dst)224 if not os.path.isdir(dst_dir):225 os.makedirs(dst_dir)226 if os.path.exists(dst):227 os.remove(dst)228 try:229 os.link(src, dst)230 # Qt uses LF-only but Chromium isn't.231 subprocess.call(['dos2unix', '--keep-bom', '--quiet', dst])232 except OSError as exception:233 if exception.errno == errno.ENOENT:234 print 'file does not exist:' + src235 else:236 raise237third_party_upstream = os.path.join(qtwebengine_root, 'src/3rdparty_upstream')238third_party = os.path.join(qtwebengine_root, 'src/3rdparty')239def clearDirectory(directory):240 currentDir = os.getcwd()241 os.chdir(directory)242 print 'clearing the directory:' + directory243 for direntry in os.listdir(directory):244 if not direntry == '.git' and os.path.isdir(direntry):245 print 'clearing:' + direntry246 shutil.rmtree(direntry)247 os.chdir(currentDir)248def listFilesInCurrentRepository():249 currentRepo = GitSubmodule.Submodule(os.getcwd())250 files = subprocess.check_output(['git', 'ls-files']).splitlines()251 submodules = currentRepo.readSubmodules()252 for submodule in submodules:253 submodule_files = submodule.listFiles()254 for submodule_file in submodule_files:255 files.append(os.path.join(submodule.path, submodule_file))256 return files257def exportNinja():258 third_party_upstream_ninja = os.path.join(third_party_upstream, 'ninja')259 third_party_ninja = os.path.join(third_party, 'ninja')260 os.makedirs(third_party_ninja);261 print 'exporting contents of:' + third_party_upstream_ninja262 os.chdir(third_party_upstream_ninja)263 files = listFilesInCurrentRepository()264 print 'copying files to ' + third_party_ninja265 for i in xrange(len(files)):266 printProgress(i+1, len(files))267 f = files[i]268 if not isInGitBlacklist(f):269 copyFile(f, os.path.join(third_party_ninja, f))270 print("")271def exportChromium():272 third_party_upstream_chromium = os.path.join(third_party_upstream, 'chromium')273 third_party_chromium = os.path.join(third_party, 'chromium')274 os.makedirs(third_party_chromium);275 print 'exporting contents of:' + third_party_upstream_chromium276 os.chdir(third_party_upstream_chromium)277 files = listFilesInCurrentRepository()278 # Add LASTCHANGE files which are not tracked by git.279 files.append('build/util/LASTCHANGE')280 files.append('build/util/LASTCHANGE.blink')281 print 'copying files to ' + third_party_chromium282 for i in xrange(len(files)):283 printProgress(i+1, len(files))284 f = files[i]285 if not isInChromiumBlacklist(f) and not isInGitBlacklist(f):286 copyFile(f, os.path.join(third_party_chromium, f))287 print("")288commandNotFound = subprocess.call(['which', 'dos2unix'])289if not commandNotFound:290 dos2unixVersion , err = subprocess.Popen(['dos2unix', '-V', '| true'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()291 if not dos2unixVersion:292 raise Exception("You need dos2unix version 6.0.6 minimum.")293 dos2unixVersion = StrictVersion(dos2unixVersion.splitlines()[0].split()[1])294if commandNotFound or dos2unixVersion < StrictVersion('6.0.6'):295 raise Exception("You need dos2unix version 6.0.6 minimum.")296os.chdir(third_party)297ignore_case_setting = subprocess.Popen(['git', 'config', '--get', 'core.ignorecase'], stdout=subprocess.PIPE).communicate()[0]298if 'true' in ignore_case_setting:299 raise Exception("Your 3rdparty repository is configured to ignore case. "300 "A snapshot created with these settings would cause problems on case sensitive file systems.")301clearDirectory(third_party)302exportNinja()303exportChromium()...
code_test.py
Source:code_test.py
1def get_category(dest):2 if dest.startswith("/s/") or dest.startswith("/download/resources"):3 return "static"4 if dest.startswith("images"):5 return "images"6 if dest.startswith("/projects/"):7 return "projects"8 if dest.startswith("/?") or dest == "/secure/" or dest.startswith(9 "/secure/default.jsp"):10 return 'Home'11 if dest.startswith("/default.jsp?clicked=footer") or (dest == ""):12 return 'Home'13 if dest.startswith("/secure/IssueNavigator.jspa") or dest.startswith(14 "/secure/IssueNavigator!"):15 return 'IssueNavigator'16 if dest.startswith("/issues/"):17 return 'Issues'18 if dest == "/i":19 return 'Issues'20 if dest.startswith("/secure/BrowseProjects.jspa"):21 return 'BrowseProjects'22 if dest.startswith("/secure/BrowseProject.jspa"):23 return 'BrowseProject'24 if dest == "/browse/" or dest == "/browse":25 return 'BrowseProject'26 if dest == "/includes/jira/issue/searchIssueTypes.js":27 return 'INCLUDES'28 if dest.startswith("/includes/blank.html?"):29 return 'INCLUDES'30 if dest == "/includes/deployJava.js":31 return 'INCLUDES'32 if dest.startswith("/includes/js"):33 return 'INCLUDES'34 if dest.startswith("/rpc/soap"):35 return 'RPC'36 if dest.startswith("/rpc/xmlrpc"):37 return 'RPC'38 if dest.startswith("/rpc/json-rpc"):39 return 'RPC'40 if dest.startswith("/secure/WikiRendererHelpAction.jspa"):41 return 'WikiRendererHelp'42 if dest.startswith("/secure/ViewUserHover!default.jspa"):43 return 'ViewUserHover'44 if dest.startswith("/secure/popups/UserPickerBrowser.jspa"):45 return 'UserPickerBrowser'46 if dest.startswith("/secure/UpdateUserPreferences.jspa") or dest.startswith(47 "/secure/UpdateUserPreferences!"):48 return 'UpdateUserPreferences'49 if dest.startswith("/secure/Dashboard.jspa") or dest.startswith(50 "Dashboard.jspa"):51 return 'Dashboard'52 if dest.startswith("/secure/ViewProfile.jspa"):53 return 'ViewProfile'54 if dest.startswith("/sr/jira.issueviews:searchrequest-xml/"):55 return 'SearchRequest_XML'56 if dest.startswith(57 "/sr/jira.issueviews:searchrequest-rss") or dest.startswith(58 "/sr/jira.issueviews%3Asearchrequest-rss"):59 return 'SearchRequest_RSS'60 if dest.startswith("/sr/jira.issueviews:searchrequest-comments-rss/"):61 return 'SearchRequest_RSS'62 if dest.startswith(63 "/sr/jira.issueviews:searchrequest-excel-current-fields"):64 return 'SearchRequest_Excel'65 if dest.startswith("/secure/CreateIssue.jspa") or dest.startswith(66 "/secure/CreateIssue!") or dest.startswith(67 "/secure/CreateIssueDetails!") or dest.startswith(68 "/secure/CreateIssueDetails.jspa") or dest.startswith(69 "/secure/CreateSubTaskIssueDetails.jspa") or dest.startswith(70 "/secure/CreateSubTaskIssue.jspa") or dest.startswith(71 "/secure/CreateSubTaskIssue!"):72 return 'CreateIssue'73 if dest.startswith("/secure/QuickCreateIssue!default.jspa"):74 return 'CreateIssue'75 if dest.startswith("/secure/ReleaseNote.jspa"):76 return 'ReleaseNote'77 if dest.startswith("/secure/QuickSearch.jspa"):78 return 'QuickSearch'79 if dest.startswith("/rest/activity-stream"):80 return 'REST_ACTIVITY_STREAM'81 if dest.startswith("/rest/greenhopper/1.0/xboard"):82 return 'REST_greenhopper_xboard'83 if dest.startswith("/rest/greenhopper/1.0/rapidview"):84 return 'REST_greenhopper_rapidview'85 if dest.startswith("/rest/greenhopper"):86 return 'REST_greenhopper'87 if dest.startswith("/rest/crm/"):88 return 'REST_CRM'89 if dest.startswith("/rest/myrestresource/"):90 return 'REST_myrestresource'91 if dest.startswith("/rest/whoslooking/"):92 return 'REST_whoslooking'93 if dest.startswith("/rest/dashboards/"):94 return 'REST_dashboards'95 if dest.startswith("/login.jsp") or dest.startswith("/loginsso.jsp"):96 return 'Login'97 if dest.startswith("/secure/Logout!") or dest.startswith("/logout"):98 return 'Logout'99 if dest.startswith("/secure/attachment/"):100 return 'ATTACHMENTS'101 if dest.startswith("/secure/attachmentzip/unzip/"):102 return 'ATTACHMENTS'103 if dest.startswith("/secure/ManageAttachments.jspa") or dest.startswith(104 "/secure/ManageAttachments!") or dest.startswith(105 "/secure/AttachFile"):106 return 'ATTACHMENTS'107 if dest.startswith("/secure/DeleteAttachment.jspa") or dest.startswith(108 "/secure/DeleteAttachment!") or dest.startswith(109 "/secure/AttachFile"):110 return 'ATTACHMENTS'111 if dest.startswith("/secure/AttachTemporaryFile.jspa"):112 return 'ATTACHMENTS'113 if dest.startswith("/plugins/servlet/streams"):114 return 'ACTIVITY_STREAMS'115 if dest.startswith("/activity?"):116 return 'ACTIVITY_STREAMS'117 if dest.startswith("/plugins/servlet/gadgets/"):118 return 'GADGETS'119 if dest.startswith("/rest/gadgets"):120 return 'GADGETS'121 if dest.startswith("/secure/RunPortlet.jspa"):122 return 'RunPortlet'123 if dest.startswith("/secure/useravatar"):124 return 'USER_AVATAR'125 if (dest == "/osd.jsp"):126 return 'OpenSearch'127 if dest.startswith("/secure/WorkflowUIDispatcher.jspa"):128 return 'WorkflowTransition'129 if dest.startswith("/secure/CommentAssignIssue!default.jspa") or \130 dest.startswith("/secure/CommentAssignIssue.jspa"):131 return 'WorkflowTransition'132 if dest.startswith("/secure/SaveAsFilter!") or dest.startswith(133 "/secure/SaveAsFilter.jspa"):134 return 'SaveAsFilter'135 if dest.startswith("/secure/ManageFilters!") or dest.startswith(136 "/secure/ManageFilters.jspa"):137 return 'ManageFilters'138 if dest.startswith("/secure/RapidBoard.jspa") or (139 dest == "/secure/GreenHopper.jspa"):140 return 'GreenHopper'141 if dest.startswith("/secure/EditAction"):142 return 'EditAction'143 if dest.startswith("/secure/ViewIssue.jspa"):144 return 'ViewIssue'145 if dest.startswith("/secure/AjaxIssueAction.jspa") or dest.startswith(146 "/secure/AjaxIssueAction!"):147 return 'AjaxIssueAction'148 if dest.startswith("/secure/AjaxIssueEditAction.jspa") or dest.startswith(149 "/secure/AjaxIssueEditAction!"):150 return 'AjaxIssueEditAction'151 if dest.startswith("/si/jira.issueviews:issue-xml/"):152 return 'IssueXml'153 if dest.startswith("/secure/EditIssue") or dest.startswith(154 "/secure/EditSubTaskIssue"):155 return 'EditIssue'156 if dest.startswith("/secure/DeleteIssue"):157 return 'DeleteIssue'158 if dest.startswith(159 "/secure/QuickEditIssue!default.jspa") or dest.startswith(160 "/secure/QuickEditIssue.jspa"):161 return 'EditIssue'162 if dest.startswith("/secure/MoveIssue"):163 return 'MoveIssue'164 if dest.startswith("/secure/AddComment.jspa") or dest.startswith(165 "/secure/AddComment!"):166 return 'AddComment'167 if dest.startswith("/secure/CreateWorklog.jspa") or dest.startswith(168 "/secure/CreateWorklog!"):169 return 'CreateWorklog'170 if dest.startswith("/secure/EditComment"):171 return 'EditComment'172 if dest.startswith("/secure/QuickCreateIssue"):173 return 'QuickCreateIssue'174 """ 175 if ((requestMethod == RequestMethod.GET) & & dest.startswith(176 "/secure/IssueAction!default.jspa"):177 return 'INLINE_EDIT_REFRESH'178 179 if ((requestMethod == RequestMethod.POST) & & dest.startswith(180 "/secure/IssueAction!default.jspa"):181 return 'INLINE_EDIT_POST'182 183 if ((requestMethod == RequestMethod.POST) & & dest.startswith(184 "/secure/IssueAction.jspa"):185 return 'INLINE_EDIT_POST'186 """187 if dest.startswith("/secure/views/bulkedit/"):188 return 'BulkOperation'189 if dest.startswith("/secure/EditLabels!") or dest.startswith(190 "/secure/EditLabels.jspa"):191 return 'EditLabels'192 if dest.startswith("/charts?filename="):193 return 'Charts'194 if dest.startswith("/secure/QueryComponent"):195 return 'QueryComponent'196 if dest.startswith("/secure/VoteOrWatchIssue.jspa"):197 return 'VoteOrWatchIssue'198 if dest.startswith("/secure/projectavatar"):199 return 'ProjectAvatar'200 if dest.startswith("/secure/AssignIssue"):201 return 'AssignIssue'202 if dest.startswith("/rest/gadget"):203 return 'REST_GADGET'204 if dest.startswith("/secure/RankTop.jspa") or dest.startswith(205 "/secure/RankBottom.jspa") or dest.startswith(206 "/secure/GHGoToBoard.jspa") or dest.startswith(207 "/secure/GHLocateIssueOnBoard.jspa") or dest.startswith(208 "/secure/GHLocateSprintOnBoard.jspa"):209 return 'GreenHopper'210 if dest.startswith("/secure/VersionBoard.jspa") or dest.startswith(211 "/secure/VersionBoard!"):212 return 'GreenHopper'213 if dest.startswith("/secure/TaskBoard.jspa") or dest.startswith(214 "/secure/TaskBoard!"):215 return 'GreenHopper'216 if dest.startswith("/secure/VBRefreshBoard.jspa") or dest.startswith(217 "/secure/VBRefreshBoard!"):218 return 'GreenHopper'219 if dest.startswith("/secure/VBRefreshBreadcrumbs.jspa") or dest.startswith(220 "/secure/VBRefreshBreadcrumbs!"):221 return 'GreenHopper'222 if dest.startswith("/secure/BoardOptions.jspa") or dest.startswith(223 "/secure/BoardOptions!"):224 return 'GreenHopper'225 if dest.startswith("/secure/SearchBoard.jspa") or dest.startswith(226 "/secure/SearchBoard!"):227 return 'GreenHopper'228 if dest.startswith("/secure/ChartBoard.jspa") or dest.startswith(229 "/secure/ChartBoard!"):230 return 'GreenHopper'231 if dest.startswith("/secure/GetBoardForIssue2.jspa") or dest.startswith(232 "/secure/GetBoardForIssue2!"):233 return 'GreenHopper'234 if dest.startswith("/secure/GHCreateNewIssue.jspa") or dest.startswith(235 "/secure/GHCreateNewIssue!"):236 return 'GreenHopper'237 if dest.startswith("/secure/GHAddIssue.jspa") or dest.startswith(238 "/secure/GHAddIssue!"):239 return 'GreenHopper'240 if dest.startswith("/secure/GreenHopperClassic.jspa") or dest.startswith(241 "/secure/GreenHopperClassic!"):242 return 'GreenHopper'243 if dest.startswith("/secure/RapidView.jspa") or dest.startswith(244 "/secure/RapidView!"):245 return 'GreenHopper'246 if dest.startswith("/secure/ManageRapidViews.jspa") or dest.startswith(247 "/secure/ManageRapidViews!"):248 return 'GreenHopper'249 if dest.startswith("/secure/MyJiraHome.jspa"):250 return 'MyJiraHome'251 if dest.startswith("/secure/thumbnail"):252 return 'Thumbnail'253 if dest.startswith("/plugins/servlet"):254 return 'PLUGINS_SERVLET'255 if dest.startswith("/secure/LinkJiraIssue.jspa") or dest.startswith(256 "/secure/LinkJiraIssue!"):257 return 'LinkJiraIssue'258 if dest.startswith("/download/resources/"):259 return 'PLUGIN_RESOURCES'260 if dest.startswith("/lazyLoader"):261 return 'LazyPortletLoader'262 if dest.startswith("/dwr/"):263 return 'DWR'264 if dest.startswith("/s/"):265 return 'STATIC_RESOURCE'266 if dest.startswith("/images/"):267 return 'STATIC_RESOURCE'268 if dest == "/styles/combined.css" or dest == "/styles/global.css":269 return 'STATIC_RESOURCE'270 if dest == "/favicon.ico" or dest == "/robots.txt":271 return 'STATIC_RESOURCE'272 if dest.startswith("/images/throbber/") or dest.startswith(273 "/download/batch/com.atlassian.upm.atlassian-universal-plugin"274 "-manager"275 "-plugin:upgrade-notification/com.atlassian.upm.atlassian-universal"276 "-plugin-manager-plugin:upgrade-notification.js"):277 return 'STATIC_RESOURCE'278 if dest.startswith("/secure/project/"):279 return 'ProjectAdmin'280 if dest.startswith("/secure/admin") or dest.startswith(281 "/secure/AdminSummary.jspa"):282 return 'ADMIN'283 if dest.startswith("/secure/SetSelectedIssue.jspa"):284 return 'SetSelectedIssue'285 if dest.startswith("/rest/collectors/"):286 return 'REST_COLLECTORS'287 if dest.startswith("/rest/analytics/"):288 return 'REST_ANALYTICS'289 if dest.startswith("/rest/capabilities"):290 return 'REST_CAPABILITIES'291 if dest.startswith("/rest/menu/"):292 return 'REST_MENU'293 if dest.startswith("/rest/nav-links-analytics-data/"):294 return 'REST_NAV_LINKS_ANALYTICS_DATA'295 if dest.startswith("/rest/mobile/"):296 return 'REST_MOBILE'297 if dest.startswith("/rest/issueNav/"):298 return 'REST_ISSUE_NAV'299 if dest.startswith("/rest/helptips/"):300 return 'REST_HELP_TIPS'301 if dest.startswith("/rest/viewIssue/"):302 return 'REST_HELP_TIPS'303 if dest.startswith("/rest/lasso/"):304 return 'REST_LASSO'305 if dest.startswith("/rest/api/2/search"):306 return 'REST_API_SEARCH'307 if dest.startswith("/rest/api/2/filter/"):308 return 'REST_API_FILTER'309 if dest.startswith("/rest/api/1.0/shortcuts"):310 return 'REST_API_SHORTCUTS'311 if dest.startswith("/rest/api/"):312 return 'REST_API'313 if dest.startswith("/rest/scriptrunner/"):314 return 'REST_scriptrunner'315 if dest.startswith("/rest/scriptrunner-jira/"):316 return 'REST_scriptrunner'317 if dest.startswith("/rest/remote-link-aggregation/"):318 return 'REST_remote_link_aggregation'319 if dest.startswith("/rest/com.onresolve.jira.plugin.Behaviours/"):320 return 'REST_onresolveBehaviours'321 if dest.startswith("/rest/jeditortemplateresource/"):322 return 'REST_jeditortemplateresource'323 if dest.startswith("/rest/bamboo/"):324 return 'REST_bamboo'325 if dest.startswith("/rest/"):326 return 'REST_OTHER'327 if dest.startswith("/secure/errors.jsp"):328 return 'Errors_jsp'329 if dest.startswith("/TempoIssuePanel!default.jspa"):330 return 'TempoIssuePanel'331 if dest.startswith("/secure/Tempo") or dest.startswith("/Tempo"):...
SafeLink.js
Source:SafeLink.js
...145 /// based on Android handleIntent function146 handleSafeClick = async event => {147 event.stopPropagation();148 let { onClick, url: href } = this.props;149 href = href.startsWith('http') || href.startsWith('tg://') ? href : 'https://' + href;150 let handled = false;151 if (isTelegramLink(href)) {152 event.preventDefault();153 try {154 const url = new URL(href);155 console.log('[SafeLink] url', url);156 switch (url.protocol) {157 case 'http:':158 case 'https:': {159 if (url.pathname.startsWith('/bg/')) {160 } else if (url.pathname.startsWith('/login/')) {161 } else if (url.pathname.startsWith('/joinchat/')) {162 } else if (url.pathname.startsWith('/addstickers/')) {163 const set = url.pathname.replace('/addstickers/', '');164 await this.handleAddStickersLink(set);165 handled = true;166 } else if (url.pathname.startsWith('/mgs/') || url.pathname.startsWith('/share/')) {167 } else if (url.pathname.startsWith('/confirmphone/')) {168 } else if (url.pathname.startsWith('/setlanguage/')) {169 } else if (url.pathname.startsWith('/addtheme/')) {170 } else if (url.pathname.startsWith('/c/')) {171 await this.handlePrivatePost(url);172 handled = true;173 } else if (url.pathname.length > 1) {174 const username = url.pathname[0] === '/' ? url.pathname.substr(1) : url.pathname;175 if (username) {176 if (url.searchParams.has('start')){177 await this.handleBotStart(username, url.searchParams.get('start'), false);178 handled = true;179 } else if (url.searchParams.has('startgroup')) {180 await this.handleBotStart(username, url.searchParams.get('startgroup'), true);181 handled = true;182 } else if (url.searchParams.has('game')) {183 await this.handleOpenUsername(username);184 handled = true;185 } else if (url.searchParams.has('post')) {186 } else if (url.searchParams.has('thread')) {187 } else if (url.searchParams.has('comment')) {188 }189 if (!handled) {190 await this.handleOpenMessageLinkInfo(href);191 handled = true;192 }193 }194 }195 break;196 }197 case 'tg:': {198 if (href.startsWith('tg:resolve') || href.startsWith('tg://resolve')) {199 const username = url.searchParams('domain');200 if (username) {201 if (username === 'telegrampassport') {202 } else {203 if (url.searchParams.has('start')){204 await this.handleBotStart(username, url.searchParams.get('start'), false);205 handled = true;206 } else if (url.searchParams.has('startgroup')) {207 await this.handleBotStart(username, url.searchParams.get('startgroup'), true);208 handled = true;209 } else if (url.searchParams.has('game')) {210 await this.handleOpenUsername(username);211 handled = true;212 } else if (url.searchParams.has('post')) {213 } else if (url.searchParams.has('thread')) {214 } else if (url.searchParams.has('comment')) {215 }216 if (!handled) {217 await this.handleOpenMessageLinkInfo(href);218 handled = true;219 }220 }221 }222 } else if (href.startsWith('tg:privatepost') || href.startsWith('tg://privatepost')) {223 await this.handlePrivatePost(url)224 handled = true;225 } else if (href.startsWith('tg:bg') || href.startsWith('tg://bg')) {226 } else if (href.startsWith('tg:join') || href.startsWith('tg://join')) {227 } else if (href.startsWith('tg:addstickers') || href.startsWith('tg://addstickers')) {228 const set = url.searchParams.get('set');229 await this.handleAddStickersLink(set);230 handled = true;231 } else if (href.startsWith('tg:msg') || href.startsWith('tg://msg') || href.startsWith('tg:share') || href.startsWith('tg://share')) {232 } else if (href.startsWith('tg:confirmphone') || href.startsWith('tg://confirmphone')) {233 } else if (href.startsWith('tg:login') || href.startsWith('tg://login')) {234 } else if (href.startsWith('tg:openmessage') || href.startsWith('tg://openmessage')) {235 } else if (href.startsWith('tg:passport') || href.startsWith('tg://passport') || href.startsWith('tg:secureid') || href.startsWith('tg://secureid')) {236 } else if (href.startsWith('tg:setlanguage') || href.startsWith('tg://setlanguage')) {237 } else if (href.startsWith('tg:addtheme') || href.startsWith('tg://addtheme')) {238 } else if (href.startsWith('tg:settings') || href.startsWith('tg://settings')) {239 } else if (href.startsWith('tg:search') || href.startsWith('tg://search')) {240 } else if (href.startsWith('tg:calllog') || href.startsWith('tg://calllog')) {241 } else if (href.startsWith('tg:call') || href.startsWith('tg://call')) {242 } else if (href.startsWith('tg:scanqr') || href.startsWith('tg://scanqr')) {243 } else if (href.startsWith('tg:addcontact') || href.startsWith('tg://addcontact')) {244 } else if (href.startsWith('tg:bot_command') || href.startsWith('tg://bot_command')) {245 const command = url.searchParams.get('command');246 const bot = url.searchParams.get('bot');247 this.handleBotCommand(`/${command}` + (bot ? `@${bot}` : ''));248 handled = true;249 } else {250 await this.handleUnknownDeepLink(href);251 handled = true;252 }253 break;254 }255 }256 } catch (error) {257 console.log('[safeLink] handleSafeLink error', error);258 handled = false;...
StartsWith.js
Source:StartsWith.js
1// Tests taken from https://mths.be/startswith2Object.prototype[1] = 2; // try to break `arguments[1]`3assert.equal(String.prototype.startsWith.length, 1);4assert.equal("undefined".startsWith(), true);5assert.equal("undefined".startsWith(undefined), true);6assert.equal("undefined".startsWith(null), false);7assert.equal("null".startsWith(), false);8assert.equal("null".startsWith(undefined), false);9assert.equal("null".startsWith(null), true);10assert.equal("abc".startsWith(), false);11assert.equal("abc".startsWith(""), true);12assert.equal("abc".startsWith("\0"), false);13assert.equal("abc".startsWith("a"), true);14assert.equal("abc".startsWith("b"), false);15assert.equal("abc".startsWith("ab"), true);16assert.equal("abc".startsWith("bc"), false);17assert.equal("abc".startsWith("abc"), true);18assert.equal("abc".startsWith("bcd"), false);19assert.equal("abc".startsWith("abcd"), false);20assert.equal("abc".startsWith("bcde"), false);21assert.equal("abc".startsWith("", NaN), true);22assert.equal("abc".startsWith("\0", NaN), false);23assert.equal("abc".startsWith("a", NaN), true);24assert.equal("abc".startsWith("b", NaN), false);25assert.equal("abc".startsWith("ab", NaN), true);26assert.equal("abc".startsWith("bc", NaN), false);27assert.equal("abc".startsWith("abc", NaN), true);28assert.equal("abc".startsWith("bcd", NaN), false);29assert.equal("abc".startsWith("abcd", NaN), false);30assert.equal("abc".startsWith("bcde", NaN), false);31assert.equal("abc".startsWith("", false), true);32assert.equal("abc".startsWith("\0", false), false);33assert.equal("abc".startsWith("a", false), true);34assert.equal("abc".startsWith("b", false), false);35assert.equal("abc".startsWith("ab", false), true);36assert.equal("abc".startsWith("bc", false), false);37assert.equal("abc".startsWith("abc", false), true);38assert.equal("abc".startsWith("bcd", false), false);39assert.equal("abc".startsWith("abcd", false), false);40assert.equal("abc".startsWith("bcde", false), false);41assert.equal("abc".startsWith("", undefined), true);42assert.equal("abc".startsWith("\0", undefined), false);43assert.equal("abc".startsWith("a", undefined), true);44assert.equal("abc".startsWith("b", undefined), false);45assert.equal("abc".startsWith("ab", undefined), true);46assert.equal("abc".startsWith("bc", undefined), false);47assert.equal("abc".startsWith("abc", undefined), true);48assert.equal("abc".startsWith("bcd", undefined), false);49assert.equal("abc".startsWith("abcd", undefined), false);50assert.equal("abc".startsWith("bcde", undefined), false);51assert.equal("abc".startsWith("", null), true);52assert.equal("abc".startsWith("\0", null), false);53assert.equal("abc".startsWith("a", null), true);54assert.equal("abc".startsWith("b", null), false);55assert.equal("abc".startsWith("ab", null), true);56assert.equal("abc".startsWith("bc", null), false);57assert.equal("abc".startsWith("abc", null), true);58assert.equal("abc".startsWith("bcd", null), false);59assert.equal("abc".startsWith("abcd", null), false);60assert.equal("abc".startsWith("bcde", null), false);61assert.equal("abc".startsWith("", -Infinity), true);62assert.equal("abc".startsWith("\0", -Infinity), false);63assert.equal("abc".startsWith("a", -Infinity), true);64assert.equal("abc".startsWith("b", -Infinity), false);65assert.equal("abc".startsWith("ab", -Infinity), true);66assert.equal("abc".startsWith("bc", -Infinity), false);67assert.equal("abc".startsWith("abc", -Infinity), true);68assert.equal("abc".startsWith("bcd", -Infinity), false);69assert.equal("abc".startsWith("abcd", -Infinity), false);70assert.equal("abc".startsWith("bcde", -Infinity), false);71assert.equal("abc".startsWith("", -1), true);72assert.equal("abc".startsWith("\0", -1), false);73assert.equal("abc".startsWith("a", -1), true);74assert.equal("abc".startsWith("b", -1), false);75assert.equal("abc".startsWith("ab", -1), true);76assert.equal("abc".startsWith("bc", -1), false);77assert.equal("abc".startsWith("abc", -1), true);78assert.equal("abc".startsWith("bcd", -1), false);79assert.equal("abc".startsWith("abcd", -1), false);80assert.equal("abc".startsWith("bcde", -1), false);81assert.equal("abc".startsWith("", -0), true);82assert.equal("abc".startsWith("\0", -0), false);83assert.equal("abc".startsWith("a", -0), true);84assert.equal("abc".startsWith("b", -0), false);85assert.equal("abc".startsWith("ab", -0), true);86assert.equal("abc".startsWith("bc", -0), false);87assert.equal("abc".startsWith("abc", -0), true);88assert.equal("abc".startsWith("bcd", -0), false);89assert.equal("abc".startsWith("abcd", -0), false);90assert.equal("abc".startsWith("bcde", -0), false);91assert.equal("abc".startsWith("", +0), true);92assert.equal("abc".startsWith("\0", +0), false);93assert.equal("abc".startsWith("a", +0), true);94assert.equal("abc".startsWith("b", +0), false);95assert.equal("abc".startsWith("ab", +0), true);96assert.equal("abc".startsWith("bc", +0), false);97assert.equal("abc".startsWith("abc", +0), true);98assert.equal("abc".startsWith("bcd", +0), false);99assert.equal("abc".startsWith("abcd", +0), false);100assert.equal("abc".startsWith("bcde", +0), false);101assert.equal("abc".startsWith("", 1), true);102assert.equal("abc".startsWith("\0", 1), false);103assert.equal("abc".startsWith("a", 1), false);104assert.equal("abc".startsWith("b", 1), true);105assert.equal("abc".startsWith("ab", 1), false);106assert.equal("abc".startsWith("bc", 1), true);107assert.equal("abc".startsWith("abc", 1), false);108assert.equal("abc".startsWith("bcd", 1), false);109assert.equal("abc".startsWith("abcd", 1), false);110assert.equal("abc".startsWith("bcde", 1), false);111assert.equal("abc".startsWith("", +Infinity), true);112assert.equal("abc".startsWith("\0", +Infinity), false);113assert.equal("abc".startsWith("a", +Infinity), false);114assert.equal("abc".startsWith("b", +Infinity), false);115assert.equal("abc".startsWith("ab", +Infinity), false);116assert.equal("abc".startsWith("bc", +Infinity), false);117assert.equal("abc".startsWith("abc", +Infinity), false);118assert.equal("abc".startsWith("bcd", +Infinity), false);119assert.equal("abc".startsWith("abcd", +Infinity), false);120assert.equal("abc".startsWith("bcde", +Infinity), false);121assert.equal("abc".startsWith("", true), true);122assert.equal("abc".startsWith("\0", true), false);123assert.equal("abc".startsWith("a", true), false);124assert.equal("abc".startsWith("b", true), true);125assert.equal("abc".startsWith("ab", true), false);126assert.equal("abc".startsWith("bc", true), true);127assert.equal("abc".startsWith("abc", true), false);128assert.equal("abc".startsWith("bcd", true), false);129assert.equal("abc".startsWith("abcd", true), false);130assert.equal("abc".startsWith("bcde", true), false);131assert.equal("abc".startsWith("", "x"), true);132assert.equal("abc".startsWith("\0", "x"), false);133assert.equal("abc".startsWith("a", "x"), true);134assert.equal("abc".startsWith("b", "x"), false);135assert.equal("abc".startsWith("ab", "x"), true);136assert.equal("abc".startsWith("bc", "x"), false);137assert.equal("abc".startsWith("abc", "x"), true);138assert.equal("abc".startsWith("bcd", "x"), false);139assert.equal("abc".startsWith("abcd", "x"), false);140assert.equal("abc".startsWith("bcde", "x"), false);141assert.equal("[a-z]+(bar)?".startsWith("[a-z]+"), true);142assert.throw(function () {143 "[a-z]+(bar)?".startsWith(/[a-z]+/);144}, TypeError);145assert.equal("[a-z]+(bar)?".startsWith("(bar)?", 6), true);146assert.throw(function () {147 "[a-z]+(bar)?".startsWith(/(bar)?/);148}, TypeError);149assert.throw(function () {150 "[a-z]+/(bar)?/".startsWith(/(bar)?/);151}, TypeError);152// https://mathiasbynens.be/notes/javascript-unicode#poo-test153var string = "I\xF1t\xEBrn\xE2ti\xF4n\xE0liz\xE6ti\xF8n\u2603\uD83D\uDCA9";154assert.equal(string.startsWith(""), true);155assert.equal(string.startsWith("\xF1t\xEBr"), false);156assert.equal(string.startsWith("\xF1t\xEBr", 1), true);157assert.equal(string.startsWith("\xE0liz\xE6"), false);158assert.equal(string.startsWith("\xE0liz\xE6", 11), true);159assert.equal(string.startsWith("\xF8n\u2603\uD83D\uDCA9"), false);160assert.equal(string.startsWith("\xF8n\u2603\uD83D\uDCA9", 18), true);161assert.equal(string.startsWith("\u2603"), false);162assert.equal(string.startsWith("\u2603", 20), true);163assert.equal(string.startsWith("\uD83D\uDCA9"), false);164assert.equal(string.startsWith("\uD83D\uDCA9", 21), true);165assert.throw(function () {166 String.prototype.startsWith.call(undefined);167}, TypeError);168assert.throw(function () {169 String.prototype.startsWith.call(undefined, "b");170}, TypeError);171assert.throw(function () {172 String.prototype.startsWith.call(undefined, "b", 4);173}, TypeError);174assert.throw(function () {175 String.prototype.startsWith.call(null);176}, TypeError);177assert.throw(function () {178 String.prototype.startsWith.call(null, "b");...
get_table_name.js
Source:get_table_name.js
2module.exports = function(word){3 word = word || '0';4 var Table_Name = '';5 word = word.toLowerCase();6 if (word.startsWith("a"))7 Table_Name = "words_0061";8 else9 if (word.startsWith("b"))10 Table_Name = "words_0062";11 else12 if (word.startsWith("c"))13 Table_Name = "words_0063";14 else15 if (word.startsWith("d"))16 Table_Name = "words_0064";17 else18 if (word.startsWith("e"))19 Table_Name = "words_0065";20 else21 if (word.startsWith("f"))22 Table_Name = "words_0066";23 else24 if (word.startsWith("g"))25 Table_Name = "words_0067";26 else27 if (word.startsWith("h"))28 Table_Name = "words_0068";29 else30 if (word.startsWith("i"))31 Table_Name = "words_0069";32 else33 if (word.startsWith("j"))34 Table_Name = "words_006A";35 else36 if (word.startsWith("k"))37 Table_Name = "words_006B";38 else39 if (word.startsWith("l"))40 Table_Name = "words_006C";41 else42 if (word.startsWith("m"))43 Table_Name = "words_006D";44 else45 if (word.startsWith("n"))46 Table_Name = "words_006E";47 else48 if (word.startsWith("o"))49 Table_Name = "words_006F";50 else51 if (word.startsWith("p"))52 Table_Name = "words_0070";53 else54 if (word.startsWith("q"))55 Table_Name = "words_0071";56 else57 if (word.startsWith("r"))58 Table_Name = "words_0072";59 else60 if (word.startsWith("s"))61 Table_Name = "words_0073";62 else63 if (word.startsWith("t"))64 Table_Name = "words_0074";65 else66 if (word.startsWith("u"))67 Table_Name = "words_0075";68 else69 if (word.startsWith("v"))70 Table_Name = "words_0076";71 else72 if (word.startsWith("w"))73 Table_Name = "words_0077";74 else75 if (word.startsWith("x"))76 Table_Name = "words_0078";77 else78 if (word.startsWith("y"))79 Table_Name = "words_0079";80 else81 if (word.startsWith("z"))82 Table_Name = "words_007A";83 else84 if (word.startsWith("à "))85 Table_Name = "words_00E0";86 else87 if (word.startsWith("á"))88 Table_Name = "words_00E1";89 else90 if (word.startsWith("â"))91 Table_Name = "words_00E2";92 else93 if (word.startsWith("è"))94 Table_Name = "words_00E8";95 else96 if (word.startsWith("é"))97 Table_Name = "words_00E9";98 else99 if (word.startsWith("ê"))100 Table_Name = "words_00EA";101 else102 if (word.startsWith("ì"))103 Table_Name = "words_00EC";104 else105 if (word.startsWith("Ã"))106 Table_Name = "words_00ED";107 else108 if (word.startsWith("ò"))109 Table_Name = "words_00F2";110 else111 if (word.startsWith("ó"))112 Table_Name = "words_00F3";113 else114 if (word.startsWith("ô"))115 Table_Name = "words_00F4";116 else117 if (word.startsWith("õ"))118 Table_Name = "words_00F5";119 else120 if (word.startsWith("ù"))121 Table_Name = "words_00F9";122 else123 if (word.startsWith("ú"))124 Table_Name = "words_00FA";125 else126 if (word.startsWith("ý"))127 Table_Name = "words_00FC";128 else129 if (word.startsWith("Ä"))130 Table_Name = "words_0103";131 else132 if (word.startsWith("Ä©"))133 Table_Name = "words_0129";134 else135 if (word.startsWith("Æ¡"))136 Table_Name = "words_01A1";137 else138 if (word.startsWith("Æ°"))139 Table_Name = "words_01B0";140 else141 if (word.startsWith("ạ"))142 Table_Name = "words_1EA1";143 else144 if (word.startsWith("ả"))145 Table_Name = "words_1EA3";146 else147 if (word.startsWith("ấ"))148 Table_Name = "words_1EA5";149 else150 if (word.startsWith("ầ"))151 Table_Name = "words_1EA7";152 else153 if (word.startsWith("ẩ"))154 Table_Name = "words_1EA9";155 else156 if (word.startsWith("ẫ"))157 Table_Name = "words_1EAB";158 else159 if (word.startsWith("áº"))160 Table_Name = "words_1EAD";161 else162 if (word.startsWith("ắ"))163 Table_Name = "words_1EAF";164 else165 if (word.startsWith("ẳ"))166 Table_Name = "words_1EB3";167 else168 if (word.startsWith("ẵ"))169 Table_Name = "words_1EB5";170 else171 if (word.startsWith("ẹ"))172 Table_Name = "words_1EB9";173 else174 if (word.startsWith("ẻ"))175 Table_Name = "words_1EB3";176 else177 if (word.startsWith("ẽ"))178 Table_Name = "words_1EBD";179 else180 if (word.startsWith("ế"))181 Table_Name = "words_1EBD";182 else183 if (word.startsWith("á»"))184 Table_Name = "words_1EC1";185 else186 if (word.startsWith("á»
"))187 Table_Name = "words_1EC5";188 else189 if (word.startsWith("á»"))190 Table_Name = "words_1EC7";191 else192 if (word.startsWith("á»"))193 Table_Name = "words_1EC9";194 else195 if (word.startsWith("á»"))196 Table_Name = "words_1ECB";197 else198 if (word.startsWith("á»"))199 Table_Name = "words_1ECD";200 else201 if (word.startsWith("á»"))202 Table_Name = "words_1ECF";203 else204 if (word.startsWith("á»"))205 Table_Name = "words_1ED1";206 else207 if (word.startsWith("á»"))208 Table_Name = "words_1ED3";209 else210 if (word.startsWith("á»"))211 Table_Name = "words_1ED5";212 else213 if (word.startsWith("á»"))214 Table_Name = "words_1ED8";215 else216 if (word.startsWith("á»"))217 Table_Name = "words_1EDB";218 else219 if (word.startsWith("á»"))220 Table_Name = "words_1EDD";221 else222 if (word.startsWith("á»"))223 Table_Name = "words_1EDF";224 else225 if (word.startsWith("ỡ"))226 Table_Name = "words_1EE1";227 else228 if (word.startsWith("ợ"))229 Table_Name = "words_1EE3";230 else231 if (word.startsWith("ụ"))232 Table_Name = "words_1EE5";233 else234 if (word.startsWith("ủ"))235 Table_Name = "words_1EE7";236 else237 if (word.startsWith("ứ"))238 Table_Name = "words_1EE9";239 else240 if (word.startsWith("ừ"))241 Table_Name = "words_1EEB";242 else243 if (word.startsWith("á»"))244 Table_Name = "words_1EED";245 else246 if (word.startsWith("á»±"))247 Table_Name = "words_1EE9";248 else249 if (word.startsWith("ỳ"))250 Table_Name = "words_1EF3";251 else252 if (word.startsWith("á»·"))253 Table_Name = "words_1EF7";254 else255 Table_Name = "words_num";//ký tá»± - sá»256 return Table_Name;257}...
sort_includes.py
Source:sort_includes.py
1#!/usr/bin/env python2"""Script to sort the top-most block of #include lines.3Assumes the LLVM coding conventions.4Currently, this script only bothers sorting the llvm/... headers. Patches5welcome for more functionality, and sorting other header groups.6"""7import argparse8import os9def sort_includes(f):10 """Sort the #include lines of a specific file."""11 # Skip files which are under INPUTS trees or test trees.12 if 'INPUTS/' in f.name or 'test/' in f.name:13 return14 ext = os.path.splitext(f.name)[1]15 if ext not in ['.cpp', '.c', '.h', '.inc', '.def']:16 return17 lines = f.readlines()18 look_for_api_header = ext in ['.cpp', '.c']19 found_headers = False20 headers_begin = 021 headers_end = 022 api_headers = []23 local_headers = []24 subproject_headers = []25 llvm_headers = []26 system_headers = []27 for (i, l) in enumerate(lines):28 if l.strip() == '':29 continue30 if l.startswith('#include'):31 if not found_headers:32 headers_begin = i33 found_headers = True34 headers_end = i35 header = l[len('#include'):].lstrip()36 if look_for_api_header and header.startswith('"'):37 api_headers.append(header)38 look_for_api_header = False39 continue40 if (header.startswith('<') or header.startswith('"gtest/') or41 header.startswith('"isl/') or header.startswith('"json/')):42 system_headers.append(header)43 continue44 if (header.startswith('"clang/') or header.startswith('"clang-c/') or45 header.startswith('"polly/')):46 subproject_headers.append(header)47 continue48 if (header.startswith('"llvm/') or header.startswith('"llvm-c/')):49 llvm_headers.append(header)50 continue51 local_headers.append(header)52 continue53 # Only allow comments and #defines prior to any includes. If either are54 # mixed with includes, the order might be sensitive.55 if found_headers:56 break57 if l.startswith('//') or l.startswith('#define') or l.startswith('#ifndef'):58 continue59 break60 if not found_headers:61 return62 local_headers = sorted(set(local_headers))63 subproject_headers = sorted(set(subproject_headers))64 llvm_headers = sorted(set(llvm_headers))65 system_headers = sorted(set(system_headers))66 headers = api_headers + local_headers + subproject_headers + llvm_headers + system_headers67 header_lines = ['#include ' + h for h in headers]68 lines = lines[:headers_begin] + header_lines + lines[headers_end + 1:]69 f.seek(0)70 f.truncate()71 f.writelines(lines)72def main():73 parser = argparse.ArgumentParser(description=__doc__)74 parser.add_argument('files', nargs='+', type=argparse.FileType('r+'),75 help='the source files to sort includes within')76 args = parser.parse_args()77 for f in args.files:78 sort_includes(f)79if __name__ == '__main__':...
Using AI Code Generation
1var gherkin = require('cucumber-gherkin');2';3var scenario = gherkin.parseFeature(feature).feature.children[0];4var content = scenario.steps[0].argument.content;5var result = gherkin.startsWith(content, feature);6var gherkin = require('cucumber-gherkin');7var fs = require('fs');8var feature = fs.readFileSync('feature.txt', 'utf8');9var feature = gherkin.parseFeature(feature);10var steps = feature.feature.children[0].steps;11console.log(steps);
Using AI Code Generation
1const { messages } = require('@cucumber/messages');2const gherkin = require('gherkin');3const { Parser } = gherkin;4const parser = new Parser();5`;6const envelopes = parser.parse(source);7const feature = envelopes[0].feature;8console.log(feature.children[0].scenario.steps[0].text.startsWith('hello'));9const cucumberExpressions = require('cucumber-expressions');10const { ParameterTypeRegistry, RegularExpression } = cucumberExpressions;11const parameterTypeRegistry = new ParameterTypeRegistry();12const expression = new RegularExpression(13 /^I have (\d+) cukes in my belly$/,14 [new cucumberExpressions.ParameterType('int', (s) => parseInt(s, 10), (s) => s, true)]15);16const args = expression.match('I have 7 cukes in my belly');17console.log(args[0].value.startsWith('7'));18const { messages } = require('@cucumber/messages');19const gherkin = require('gherkin');20const { Parser } = gherkin;21const parser = new Parser();22`;23const envelopes = parser.parse(source);24const feature = envelopes[0].feature;25console.log(feature.children[0].scenario.steps[0].text.startsWith('hello'));26const { messages } = require('@cucumber/messages');27const gherkin = require('gherkin');28const { Parser } = gherkin;29const parser = new Parser();30`;31const envelopes = parser.parse(source);32const feature = envelopes[0].feature;33console.log(feature.children[0].scenario.steps[0].text.startsWith('hello'));34const TagExpression = require('cucumber-tag-expressions').TagExpression;35const tagExpression = new TagExpression('not @foo');36console.log(tagExpression.evaluate(['@foo']));
Using AI Code Generation
1var gherkin = require('cucumber-gherkin');2';3var parser = new gherkin.Parser();4var ast = parser.parse(feature);5var scenario = ast.feature.children[0];6var step = scenario.steps[0];7var keyword = step.keyword;8var prefix = feature.substring(0, step.location.column - 1);9if (prefix.endsWith(keyword)) {10 console.log('Step keyword ' + keyword + ' is correctly indented');11} else {12 console.log('Step keyword ' + keyword + ' is not correctly indented');13}
Using AI Code Generation
1var Cucumber = require('cucumber');2var gherkin = Cucumber.Gherkin;3console.log(gherkin);4var gherkinDocument = gherkin.fromGherkinDocument('Feature: abc');5console.log(gherkinDocument);6var feature = gherkinDocument.feature;7console.log(feature);8var keyword = feature.keyword;9console.log(keyword);10var result = keyword.startsWith('Feature');11console.log(result);12var str = "Feature: abc";13var result = str.startsWith('Feature');14console.log(result);15{ fromGherkinDocument: [Function: fromGherkinDocument],16 getGherkinDialectNames: [Function: getGherkinDialectNames] }17{ feature:18 { type: 'Feature',19 location: { line: 1, column: 1 },20 children: [] } }21{ type: 'Feature',22 location: { line: 1, column: 1 },23 children: [] }
Using AI Code Generation
1var cucumber = require('cucumber-gherkin');2var feature = cucumber.parse('myfeature.feature');3var scenario = feature.scenarios[0];4var step = scenario.steps[0];5if(step.startsWith('Given ')) {6 console.log('This is a Given step');7}8var cucumber = require('cucumber-gherkin');9var feature = cucumber.parse('myfeature.feature');10console.log(feature.scenarios[0].description);
LambdaTest offers a detailed Cucumber testing tutorial, explaining its features, importance, best practices, and more to help you get started with running your automation testing scripts.
Here are the detailed Cucumber testing chapters to help you get started:
Get 100 minutes of automation test minutes FREE!!