{"ScriptPreparationCode":null,"TestCases":[{"Name":"RegExp string replace","Code":"const stripExtension = (path) =\u003E path.replace(/\\.\\w\u002B$/, \u0027\u0027);\r\n\r\nstripExtension(\u0027short\u0027)\r\nstripExtension(\u0027with.ext\u0027)\r\nstripExtension(\u0027longer/path/with-segments/and/an-extension.png\u0027)","IsDeferred":false},{"Name":"lastIndexOf and string.slice","Code":"const stripExtension = (path) =\u003E {\r\n const periodIndex = path.lastIndexOf(\u0027.\u0027);\r\n return periodIndex \u003C path.length - 1 ? path.slice(0, periodIndex) : path;\r\n}\r\n\r\nstripExtension(\u0027short\u0027)\r\nstripExtension(\u0027with.ext\u0027)\r\nstripExtension(\u0027longer/path/with-segments/and/an-extension.png\u0027)","IsDeferred":false},{"Name":"lastIndexOf and string.substring","Code":"const stripExtension = (path) =\u003E {\r\n const periodIndex = path.lastIndexOf(\u0027.\u0027);\r\n return periodIndex \u003C path.length - 1 ? path.substring(0, periodIndex) : path;\r\n}\r\n\r\nstripExtension(\u0027short\u0027)\r\nstripExtension(\u0027with.ext\u0027)\r\nstripExtension(\u0027longer/path/with-segments/and/an-extension.png\u0027)","IsDeferred":false},{"Name":"lastIndexOf and regexp test on rest","Code":"const extRE = /^\\.\\w\u002B$/;\r\nconst stripExtension = (path) =\u003E {\r\n const periodIndex = path.lastIndexOf(\u0027.\u0027);\r\n const rest = path.slice(periodIndex);\r\n return rest \u0026\u0026 extRE.test(rest) ? path.slice(0, periodIndex) : path;\r\n}\r\n\r\nstripExtension(\u0027short\u0027)\r\nstripExtension(\u0027with.ext\u0027)\r\nstripExtension(\u0027longer/path/with-segments/and/an-extension.png\u0027)","IsDeferred":false}]}