Permalink
Browse files

avoid errors when required via node and no location is present

  • Loading branch information...
Andrea Giammarchi
Andrea Giammarchi committed Nov 7, 2014
1 parent db01eff commit a8ad0e4e0743f37200008e8e9cd92a35f35e728c
Showing with 13 additions and 2 deletions.
  1. +1 −1 package.json
  2. +8 −1 twemoji-dist.js
  3. +4 −0 twemoji.npm.js
View
@@ -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.",
View
@@ -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(
View
@@ -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 *//*
@@ -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.