Skip to content

Commit

Permalink
Merge pull request #13 from DigitalIO/browserify-compatibility
Browse files Browse the repository at this point in the history
Browserify compatibility
  • Loading branch information
bettiolo committed Dec 3, 2014
2 parents 22c7a14 + deea4c9 commit 4657f08
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/app/oauth-signature.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
;(function() {
'use strict';

// In node there is no global Window object
var isNode = (typeof window === 'undefined');

// Check the existence of module and module.exports to detect node
var isNode = (typeof module != 'undefined' && typeof module.exports != 'undefined');
function OAuthSignature() {
}

Expand Down Expand Up @@ -277,4 +277,4 @@
} else {
window.oauthSignature = oauthSignature;
}
})();
})();
8 changes: 8 additions & 0 deletions src/app/oauth-signature.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,4 +469,12 @@ test('Produces the expected decoded signature when optional token not provided',
'The generated GET signature should match the expected RFC 3986 encoded signature by default');
assert.equal(unencodedSignature, expectedDecodedSignature,
'The generated unencoded GET signature should match the expected unencoded signature');
});

suite('Node or Browser Detection');
test('Node or Browser properly detected', function () {
var oldIsNode = (typeof window === 'undefined');
var newIsNode = (typeof module != 'undefined' && typeof module.exports != 'undefined');
assert.equal(oldIsNode, newIsNode,
'Both methods of detection should produce the same value');
});

0 comments on commit 4657f08

Please sign in to comment.