1
0
mirror of https://github.com/twitter/twemoji.git synced 2024-07-01 02:19:09 +00:00

avoid errors when required via node and no location is present

This commit is contained in:
Andrea Giammarchi 2014-11-07 10:02:24 +00:00
parent db01efff07
commit a8ad0e4e07
3 changed files with 13 additions and 2 deletions

View File

@ -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 File

@ -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 File

@ -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;