Dieses Repository beinhaltet HTML- und Javascript Code zur einer NotizenWebApp auf Basis von Web Storage. Zudem sind Mocha/Chai Tests im Browser enthalten. https://meinenotizen.netlify.app/
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.

regex.js 963B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. var safe = require('../');
  2. var test = require('tape');
  3. var good = [
  4. /\bOakland\b/,
  5. /\b(Oakland|San Francisco)\b/i,
  6. /^\d+1337\d+$/i,
  7. /^\d+(1337|404)\d+$/i,
  8. /^\d+(1337|404)*\d+$/i,
  9. RegExp(Array(26).join('a?') + Array(26).join('a')),
  10. ];
  11. test('safe regex', function (t) {
  12. t.plan(good.length);
  13. good.forEach(function (re) {
  14. t.equal(safe(re), true);
  15. });
  16. });
  17. var bad = [
  18. /^(a?){25}(a){25}$/,
  19. RegExp(Array(27).join('a?') + Array(27).join('a')),
  20. /(x+x+)+y/,
  21. /foo|(x+x+)+y/,
  22. /(a+){10}y/,
  23. /(a+){2}y/,
  24. /(.*){1,32000}[bc]/
  25. ];
  26. test('unsafe regex', function (t) {
  27. t.plan(bad.length);
  28. bad.forEach(function (re) {
  29. t.equal(safe(re), false);
  30. });
  31. });
  32. var invalid = [
  33. '*Oakland*',
  34. 'hey(yoo))',
  35. 'abcde(?>hellow)',
  36. '[abc'
  37. ];
  38. test('invalid regex', function (t) {
  39. t.plan(invalid.length);
  40. invalid.forEach(function (re) {
  41. t.equal(safe(re), false);
  42. });
  43. });