Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: String.split on an empty string may produces unexpected results #588

Closed
Kr328 opened this issue Jul 7, 2024 · 1 comment
Closed
Labels

Comments

@Kr328
Copy link

Kr328 commented Jul 7, 2024

Description

In Chrome, String.split with a limit on an empty string returns an array containing an empty string, but goja returns an empty array.

Reproduce

Goja:

"".split("#", 2) // result == []

Excpeted Result

Chrome:

"".split("#", 2) // result == [""]

Possible Solution

Maybe add a minimum value at

goja/builtin_string.go

Lines 830 to 832 in eb1f15e

if limit > len(str) {
limit = len(str)
}

@dop251 dop251 closed this as completed in b1681fb Jul 7, 2024
@dop251 dop251 added the bug label Jul 7, 2024
@dop251
Copy link
Owner

dop251 commented Jul 7, 2024

Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants