Skip to content

Commit

Permalink
avoid errors when required via node and no location is present
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Giammarchi committed Nov 7, 2014
1 parent db01eff commit a8ad0e4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.0",
"version": "1.0.1",
"name": "twemoji",
"license": ["MIT", "CC-BY-4.0"],
"description": "A Unicode standard based way to implement emoji across all platforms.",
Expand Down
9 changes: 8 additions & 1 deletion twemoji-dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ var fs = require('fs');

fs.writeFileSync(
'twemoji.npm.js',
fs.readFileSync('twemoji.js') + '\nmodule.exports = twemoji;'
[
'var location = global.location || {};',
fs.readFileSync('twemoji.js'),
'if (!location.protocol) {',
' twemoji.base = twemoji.base.replace(/^http:/, "");',
'}',
'module.exports = twemoji;'
].join('\n')
);

fs.writeFileSync(
Expand Down
4 changes: 4 additions & 0 deletions twemoji.npm.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var location = global.location || {};
/*jslint indent: 2, browser: true, bitwise: true, plusplus: true */
var twemoji = (function (
/*! Copyright Twitter Inc. and other contributors. Licensed under MIT *//*
Expand Down Expand Up @@ -510,4 +511,7 @@ var twemoji = (function (
}

}());
if (!location.protocol) {
twemoji.base = twemoji.base.replace(/^http:/, "");
}
module.exports = twemoji;

0 comments on commit a8ad0e4

Please sign in to comment.