Skip to content

Commit 94111b9

Browse files
committed
use String.prototype.endsWith instead of .lastIndexOf with a length comparison
1 parent 41989ad commit 94111b9

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2577,7 +2577,7 @@ function insert_toplevel_func (tree, moduleInfo) {
25772577
export function compile (tree, base_output_filename, source_filename, module_infos, options) {
25782578
let abi = (options.target_arch === "armv7" || options.target_arch === "armv7s" || options.target_arch === "x86") ? new SRetABI() : new ABI();
25792579

2580-
if (source_filename.lastIndexOf(".js") == source_filename.length - 3)
2580+
if (source_filename.endsWith(".js"))
25812581
source_filename = source_filename.substring(0, source_filename.length-3);
25822582

25832583
let this_module_info = module_infos.get(source_filename);

lib/passes/gather-imports.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class GatherImports extends TreeVisitor {
5454

5555
this.importList = [];
5656
// remove our .js suffix since all imports are suffix-free
57-
if (this.filename.lastIndexOf(".js") === this.filename.length - 3)
57+
if (this.filename.endsWith(".js"))
5858
this.filename = this.filename.substring(0, this.filename.length-3);
5959

6060
this.moduleInfo = new JSModuleInfo(this.filename);

0 commit comments

Comments
 (0)