{"ScriptPreparationCode":"\r\nfunction domain1(x, wild = \u0027n\u0027, subs = \u0027o\u0027) { \r\n return x.length \u003C 256 \u0026\u0026 new RegExp(\r\n \u0060^(?=(\u0060 \u002B // capture\r\n (wild === \u0027o\u0027 \u0026\u0026 \u0027(?:\\\\*\\\\.)?\u0027 || wild === \u0027r\u0027 \u0026\u0026 \u0027(?:\\\\*\\\\.)\u0027 || \u0027\u0027) \u002B // start with *. if allowed/required\r\n \u0060(?:[a-z\\\\d](?:[-a-z\\\\d]{0,61}[a-z\\\\d])?\\\\.)\u0060 \u002B // [a-z0-9-] up to 63 chars, can\u0027t start or end w/ dash\r\n (subs === \u0027o\u0027 \u0026\u0026 \u0027\u002B\u0027 || subs === \u0027r\u0027 \u0026\u0026 \u0027{2,}\u0027 || \u0027\u0027) \u002B // subdomains or not\r\n \u0060(?!\\\\d\u002B$)\u0060 \u002B // tld can\u0027t be all digits\r\n \u0060(?:[a-z\\\\d][-a-z\\\\d]{0,22}[a-z\\\\d])\u0060 \u002B // tld up to 24 chars\r\n \u0060))\\\\1$\u0060 // end capture\r\n , \u0027i\u0027).test(x);\r\n}\r\n\r\nfunction domain2(dom) {\r\n if(dom.indexOf(\u0027..\u0027)\u003E0) return false;\r\n if(dom.indexOf(\u0027-.\u0027)\u003E0) return false;\r\n if(dom.indexOf(\u0027.-\u0027)\u003E0) return false;\r\n if(dom[0] === \u0027-\u0027 || dom[dom.length - 1] === \u0027-\u0027) return false;\r\n const parts = dom.split(\u0027.\u0027);\r\n const last = parts.pop();\r\n if(last.length \u003E 22 || /^\\d\u002B$/.test(last)) {\r\n return false;\r\n }\r\n const valid = /^[a-z0-9\\-]\u002B$/i;\r\n return parts.every(p =\u003E {\r\n return p.length \u003C 63 \u0026\u0026 valid.test(p);\r\n });\r\n}\r\n\r\n","TestCases":[{"Name":"domain 1","Code":"domain1(\u0027eefsdsdfsdfsdfs.fdsfsddfsdfsdfs.dfsdfsdfsfdsdfs.sdffdsdfssdfdffdssdfdf.dsdfsfsddfsx.com.fdsfsddfsdfsdfs.dfsdfsdfsfdsdfs.sdffdsdfssdfdffdssdfdf.dsdfsfsddfsx.com\u0027)","IsDeferred":false},{"Name":"domain 2","Code":"domain2(\u0027eefsdsdfsdfsdfs.fdsfsddfsdfsdfs.dfsdfsdfsfdsdfs.sdffdsdfssdfdffdssdfdf.dsdfsfsddfsx.com.fdsfsddfsdfsdfs.dfsdfsdfsfdsdfs.sdffdsdfssdfdffdssdfdf.dsdfsfsddfsx.com\u0027)","IsDeferred":false}]}