Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 073b738b5e67
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9669f3fa75ea
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Dec 2, 2013

  1. String#split ignores leading and continuous whitespace

    Strech (Sergey Fedorov) committed Dec 2, 2013
    Copy the full SHA
    8d7f215 View commit details

Commits on Dec 3, 2013

  1. Merge pull request #449 from Strech/master

    String#split ignores leading and continuous whitespace
    meh committed Dec 3, 2013
    Copy the full SHA
    9669f3f View commit details
Showing with 8 additions and 6 deletions.
  1. +8 −5 opal/corelib/string.rb
  2. +0 −1 spec/opal/filters/bugs/string.rb
13 changes: 8 additions & 5 deletions opal/corelib/string.rb
Original file line number Diff line number Diff line change
@@ -622,7 +622,10 @@ def split(pattern = $; || ' ', limit = undefined)
}
}
while ((cursor = #{self}.indexOf(splat, start)) > -1 && cursor < #{self}.length) {
string = (splat == ' ') ? #{self}.replace(/[\\r\\n\\t\\v]\\s+/g, ' ')
: #{self};
while ((cursor = string.indexOf(splat, start)) > -1 && cursor < string.length) {
if (splitted + 1 == lim) {
break;
}
@@ -632,18 +635,18 @@ def split(pattern = $; || ' ', limit = undefined)
continue;
}
result.push(#{self}.substr(start, splat.length ? cursor - start : 1));
result.push(string.substr(start, splat.length ? cursor - start : 1));
splitted++;
start = cursor + (splat.length ? splat.length : 1);
}
if (#{self}.length > 0 && (limit || lim < 0 || #{self}.length > start)) {
if (#{self}.length == start) {
if (string.length > 0 && (limit || lim < 0 || string.length > start)) {
if (string.length == start) {
result.push('');
}
else {
result.push(#{self}.substr(start, #{self}.length));
result.push(string.substr(start, string.length));
}
}
1 change: 0 additions & 1 deletion spec/opal/filters/bugs/string.rb
Original file line number Diff line number Diff line change
@@ -166,7 +166,6 @@
fails "String#slice with String returns a subclass instance when given a subclass instance"
fails "String#slice with Regexp, group"

fails "String#split with String ignores leading and continuous whitespace when string is a single space"
fails "String#split with String returns subclass instances based on self"
fails "String#split with Regexp divides self on regexp matches"
fails "String#split with Regexp treats negative limits as no limit"