mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:27:35 +00:00
LibJS: Implement String.prototype.substr according to the spec
Fixes #6325 The JavaScript on the HTML Spec site that caused the crash is: window.location.hash.substr(1) Of course, window.location.hash can be the empty string. The spec allows for calling substr(1) on an empty string, but our partial implementation wasn't handling it properly.
This commit is contained in:
parent
bc9cd55da4
commit
b6093ae2e3
2 changed files with 22 additions and 16 deletions
|
@ -1,6 +1,9 @@
|
|||
test("basic functionality", () => {
|
||||
expect(String.prototype.substr).toHaveLength(2);
|
||||
|
||||
expect("".substr(1)).toBe("");
|
||||
expect("".substr()).toBe("");
|
||||
expect("".substr(-1)).toBe("");
|
||||
expect("hello friends".substr()).toBe("hello friends");
|
||||
expect("hello friends".substr(1)).toBe("ello friends");
|
||||
expect("hello friends".substr(0, 5)).toBe("hello");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue