Permalink
Browse files

Updating the message syntax test.

  • Loading branch information...
1 parent 72bfca1 commit b4e841ad2bc2f3f883a9ae843163d1651242a15b @markfinger committed Jun 18, 2012
Showing with 5 additions and 3 deletions.
  1. +2 −2 fc.js
  2. +3 −1 fc.min.js
View
4 fc.js
@@ -126,9 +126,9 @@ window.fc = (function() {
if (typeof message != 'string')
throw new TypeError('fc.publish: `message` must be a string.');
- // Case-insensitive search for alphanumeric characters, underscores,
+ // Case-insensitive test for alphanumeric characters, underscores,
// dashes and colons
- if (message.search(/^[a-z0-9_/:/-]+$/i) == -1)
+ if (!/^[a-z0-9_/:/-]+$/i.test(message))
throw new Error(
'fc.publish: `message` must be a string containing at ' +
'least one character, and composed only of alphanumeric ' +
View
4 fc.min.js
@@ -3,4 +3,6 @@
Array.prototype.forEach||(Array.prototype.forEach=function(e,g){var b,a;if(null==this)throw new TypeError("this is null or not defined");var c=Object(this),d=c.length>>>0;if("[object Function]"!={}.toString.call(e))throw new TypeError(e+" is not a function");g&&(b=g);for(a=0;a<d;){var f;a in c&&(f=c[a],e.call(b,f,a,c));a++}});
Array.prototype.filter||(Array.prototype.filter=function(e,g){if(null==this)throw new TypeError;var b=Object(this),a=b.length>>>0;if("function"!=typeof e)throw new TypeError;for(var c=[],d=0;d<a;d++)if(d in b){var f=b[d];e.call(g,f,d,b)&&c.push(f)}return c});
-window.fc=function(){function g(a){c[a.name].forEach(function(b){void 0!==b.thisArg?b.callback.call(b.thisArg,a):b.callback(a)});return a}function d(a){if("string"!=typeof a)throw new TypeError("fc.publish: `message` must be a string.");if(-1==a.search(/^[a-z0-9_/:/-]+$/i))throw Error("fc.publish: `message` must be a string containing at least one character, and composed only of alphanumeric characters, underscores, dashes and colons.");if(3<a.split(":").length)throw Error("fc.publish: `message` may contain at most three colons, example: `namespace:event:identifier`.");var b=a.split(":"),a=1==b.length?a:b[0]+":"+b[1];return a}function e(a){a=a.split(":");if(3==a.length)return a[2]}var c={};return{publish:function(a,b){var c=d(a),f=(new Date).getTime(),i=e(a);if(!(void 0===b||"object"==typeof b))throw new TypeError("fc.publish: `data` must be either undefined or an object.");return g({name:c,timestamp:f,identifier:i,data:b})},subscribe:function(a,b,h){var f=d(a);if("function"!=typeof b)throw new TypeError("fc.subscribe: `callback` must be a function.");a={messageName:f,callback:b,identifier:e(a),thisArg:h};(b=c[a.messageName])||(b=c[a.messageName]=[]);b.push(a);return a},unsubscribe:function(a){var b=e(a),a=d(a);b&&(c[a]=c[a].filter(function(a){return a.identifier!=this},b));(!b||!c[a].length)&&delete c[a];return a},registry:function(){return c}}}();
+window.fc=function(){function g(a){c[a.name].forEach(function(b){void 0!==b.thisArg?b.callback.call(b.thisArg,a):b.callback(a)});return a}function d(a){if("string"!=typeof a)throw new TypeError("fc.publish: `message` must be a string.");if(!/^[a-z0-9_/:/-]+$/i.test(a))throw Error("fc.publish: `message` must be a string containing at least one character, and composed only of alphanumeric characters, underscores, dashes and colons.");if(3<a.split(":").length)throw Error("fc.publish: `message` may contain at most three colons, example: `namespace:event:identifier`.");
+var b=a.split(":"),a=1==b.length?a:b[0]+":"+b[1];return a}function e(a){a=a.split(":");if(3==a.length)return a[2]}var c={};return{publish:function(a,b){var c=d(a),f=(new Date).getTime(),i=e(a);if(!(void 0===b||"object"==typeof b))throw new TypeError("fc.publish: `data` must be either undefined or an object.");return g({name:c,timestamp:f,identifier:i,data:b})},subscribe:function(a,b,h){var f=d(a);if("function"!=typeof b)throw new TypeError("fc.subscribe: `callback` must be a function.");a={messageName:f,
+callback:b,identifier:e(a),thisArg:h};(b=c[a.messageName])||(b=c[a.messageName]=[]);b.push(a);return a},unsubscribe:function(a){var b=e(a),a=d(a);b&&(c[a]=c[a].filter(function(a){return a.identifier!=this},b));(!b||!c[a].length)&&delete c[a];return a},registry:function(){return c}}}();

0 comments on commit b4e841a

Please sign in to comment.