1
0

ensure startsWith does not go outside string section

This commit is contained in:
2024-05-19 19:00:14 +02:00
parent 6e43c1ceb3
commit 6a137a1aa4

View File

@@ -38,7 +38,7 @@ export class StringSection {
} }
public startsWith(prefix: string, offset: number = 0) { public startsWith(prefix: string, offset: number = 0) {
return this.#parent.startsWith(prefix, this.#offset + offset); return prefix.length <= (this.#length - offset) && this.#parent.startsWith(prefix, this.#offset + offset);
} }
public substring(beginIndex: number = 0, endIndex: number = this.#length - beginIndex) { public substring(beginIndex: number = 0, endIndex: number = this.#length - beginIndex) {