Browse files

Allow strings & arrays for first param of `issue` API .

Addresses issue #167. When a string was being passed in before, it would
not immediately fail and instead see it as an array with `"string".length`
members which is dumb and wrong. Instead of making it error, I Just made
it more lenient so that the first argument can be a string or an array.
  • Loading branch information...
1 parent 824b5e8 commit 5a97e69816f21ea5b20c1a2705ab8e928b2affcb @brianloveswords brianloveswords committed May 25, 2012
Showing with 20 additions and 8 deletions.
  1. +1 −0 .gitignore
  2. +9 −1 Makefile
  3. +1 −3 fakeissuer/issuer.js
  4. +6 −3 fakeissuer/static/index.html
  5. +3 −1 static/js/issuer-parts/issuer-core.js
View
1 .gitignore
@@ -6,6 +6,7 @@
.DS_Store
*.rpm
*.tar.gz
+*.pid
/docs
/node_modules
View
10 Makefile
@@ -24,5 +24,13 @@ srpm:
test: npm
npm test
+start-issuer:
+ node fakeissuer/issuer.js > issuer.pid&
+
+stop-issuer:
+ kill `cat issuer.pid`
+
jenkins_build:
- echo 'yep'
+ echo 'yep'
+
+.PHONY: fakeissuer
View
4 fakeissuer/issuer.js
@@ -61,7 +61,5 @@ app.get('/invalid.json', function (request, response) {
});
});
-
-
-console.log('starting fake issuer');
+console.log(process.pid);
app.listen(8889);
View
9 fakeissuer/static/index.html
@@ -23,16 +23,19 @@
}
unhashed.addEventListener('click', function(){
- OpenBadges.issue(['http://localhost:8889/raw.json?email=' + encodeURIComponent(getEmail())]);
+ var url = 'http://localhost:8889/raw.json?email=' + encodeURIComponent(getEmail());
+ OpenBadges.issue(url);
},false)
hashed.addEventListener('click', function(){
- OpenBadges.issue(['http://localhost:8889/hashed.json?email=' + encodeURIComponent(getEmail())]);
+ var url = 'http://localhost:8889/hashed.json?email=' + encodeURIComponent(getEmail())
+ OpenBadges.issue([url]);
},false)
// added to test whether proper error message is thrown for invalid assertion
invalid.addEventListener('click', function(){
- OpenBadges.issue(['http://localhost:8889/invalid.json?email=' + encodeURIComponent(getEmail())]);
+ var url = 'http://localhost:8889/invalid.json?email=' + encodeURIComponent(getEmail());
+ OpenBadges.issue(url);
},false)
</script>
View
4 static/js/issuer-parts/issuer-core.js
@@ -77,7 +77,9 @@ var OpenBadges = (function() {
// https://github.com/mozilla/openbadges/wiki/Issuer-API
// The final (undocumented) argument is used for testing.
issue: function OpenBadges_issue(assertions, callback, hook) {
- // setup no-op functions if the user doesn't pass in callback or hook
+ // Setup defaults for arguments. I long for the day when javascript
+ // supports defining these in the signature.
+ assertions = typeof assertions === 'string' ? [assertions] : assertions;
hook = hook || function () {};
callback = callback || function () {};

0 comments on commit 5a97e69

Please sign in to comment.