Closed fredr closed 11 years ago
what's the use-case? when are you doing this often enough that it makes sense to not use '"foobar".should.match(/^foo/)
Agreed @travisjeffery , i think we can close this.
Well, should.js is an expressive library for asserting, and imo 'http://www.example.com/something/something'.should.startWith('http://www.example.com')
is more readable than doing a regexp.
But yes, it is possible to regexp matches that does the same thing. This PR is just a suggestion
I agree that startsWith('...') is more readable than using a regexp in many cases. Especially when looking for characters that must be escaped in a regexp such as:
someUrl.should.startWith('http://') compared to someUrl.should.match(/^http:\/\//)
someUrl.should.startWith('http://') compared to someUrl.should.match(/^http:\/\//)
this definitely makes sense
@gabrielf yeah that's a good use-case/example
@btd hmm, did I do something strange while merging here? or does the PR look ok?
@travisjeffery looks ok for me, what do you think?
Good, just wanted to squash those commits.
Ayee, that boinked attribution. One sec.
:beers:
Nice!
Added startWith() for asserting that a string starts with a given string.