Skip to content

Commit

Permalink
fix issue jonmagic#6 by resetting regex internal pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkpaul committed Apr 12, 2012
1 parent 8dc32ee commit 43e2fd6
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 59 deletions.
109 changes: 66 additions & 43 deletions application.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions scripts/application.coffee
Expand Up @@ -106,6 +106,7 @@ class Results
result.push({index:index,length:length})
break if length+index == 0
value = value.substr(length+index)
regex.lastIndex = 0
result

drawResult: (string) ->
Expand Down
6 changes: 6 additions & 0 deletions spec/ResultsSpec.coffee
Expand Up @@ -13,6 +13,12 @@ describe 'Results', ->
{'regex': '"$', 'test_strings': [{'string': '"hello"'}], 'output': '"hello<span>"</span>'}
{'regex': 'a(.*)c', 'test_strings': [{'string': 'abcdd', 'matches': ['b']}], 'output': '<span>abc</span>dd'}
{'regex': 'f(oo)', 'test_strings': [{'string': 'foodbar', 'matches': ['oo']}], 'output': '<span>foo</span>dbar'}
{
'regex': 'color-stop\\((.+?)\\)'
'option':'g'
'test_strings': [{'string': '-webkit-gradient(linear, right top, left top, color-stop(0, #FF7417), color-stop(1, #82A8FF))'}]
'output': '-webkit-gradient(linear, right top, left top, <span>color-stop(0, #FF7417)</span>, <span>color-stop(1, #82A8FF)</span>)'
}
{
'regex': '^(https?)'
'test_strings': [{'string': 'https://github.com', 'matches': ['https']}]
Expand Down
34 changes: 18 additions & 16 deletions spec/ResultsSpec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 43e2fd6

Please sign in to comment.