ensure startsWith does not go outside string section
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user