diff --git a/src/string-section.ts b/src/string-section.ts index abcacb6..a4d24a2 100644 --- a/src/string-section.ts +++ b/src/string-section.ts @@ -38,7 +38,7 @@ export class StringSection { } 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) {