You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

shExpMatch.js 1.1KB

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * Module dependencies.
  3. */
  4. var assert = require('assert');
  5. var shExpMatch = require('../shExpMatch');
  6. describe('shExpMatch(str, shexp)', function () {
  7. var tests = [
  8. ["http://home.netscape.com/people/ari/index.html", "*/ari/*", true],
  9. ["http://home.netscape.com/people/montulli/index.html", "*/ari/*", false],
  10. ["http://home.example.com/people/index.html", ".*/people/.*", true],
  11. ["http://home.example.com/people/yourpage/index.html", ".*/mypage/.*", false],
  12. ["www.hotmail.com", "*hotmail.com*", true],
  13. ["phishing-scam.com?email=someone@hotmail.com", "*hotmail.com*", true],
  14. ["abcdomain.com", "(*.abcdomain.com|abcdomain.com)", true],
  15. ["foo.abcdomain.com", "(*.abcdomain.com|abcdomain.com)", true],
  16. ["abddomain.com", "(*.abcdomain.com|abcdomain.com)", false],
  17. ["a.com", "?.com", true],
  18. ["b.com", "?.com", true],
  19. ["ab.com", "?.com", false]
  20. ];
  21. tests.forEach(function (test) {
  22. var expected = test.pop();
  23. it('should return `' + expected +'` for "' + test.join('", "') + '"', function () {
  24. assert.equal(expected, shExpMatch(test[0], test[1]));
  25. });
  26. });
  27. });