Skip to content

Commit 3eb1f62

Browse files
committed
fix: update to more es6
1 parent cff7036 commit 3eb1f62

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

lib/index.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var doctypeRe = new RegExp(/^<!doctype[^>]*>\n?/im);
1+
const doctypeRe = new RegExp(/^<!doctype[^>]*>\n?/im);
22

33
function hashOf(string) {
44
let hash = 0;
@@ -60,14 +60,12 @@ function binToFile(bin, options = {}) {
6060
let meta =
6161
bin.meta ||
6262
(bin.url
63-
? `<!-- source: http://jsbin.com/${bin.url}/${bin.revision || ''} -->\n`
63+
? `<!-- source: https://jsbin.com/${bin.url}/${bin.revision || ''} -->\n`
6464
: '');
6565

6666
// insert protocol if missing
6767
html = html.replace(/(src|href)=('|")\/\//g, '$1=$2' + proto + '//');
6868

69-
// meta = meta + '<!--hash:' + bin.url + '/' + bin.revision + '/^^hash^^-->\n';
70-
7169
if (meta && meta.slice(-1) !== '\n') {
7270
meta += '\n'; // a nice new line for the meta data
7371
}
@@ -98,8 +96,8 @@ function binToFile(bin, options = {}) {
9896
file = file.split('%css%').join(bin.css);
9997
} else {
10098
// is there head tag?
101-
css = '<style id="jsbin-css">\n' + css + '\n</style>\n';
102-
var head = insert(file, '</head>', css);
99+
css = `<style id="jsbin-css">\n${css}\n</style>\n`;
100+
const head = insert(file, '</head>', css);
103101
if (head) {
104102
file = head;
105103
} else {
@@ -124,7 +122,7 @@ function binToFile(bin, options = {}) {
124122
.match(doctypeRe) || [])[0] || '';
125123

126124
if (doctype) {
127-
file = file.replace(doctypeRe, doctype + '\n' + meta);
125+
file = file.replace(doctypeRe, `${doctype}\n${meta}`);
128126
// strip from original html
129127
} else {
130128
file = meta + file;
@@ -143,7 +141,7 @@ function binToFile(bin, options = {}) {
143141
file = body;
144142
} else {
145143
// slap on the bottom
146-
file = file + '\n' + javascript;
144+
file = `${file}\n${javascript}`;
147145
}
148146
}
149147
}
@@ -187,7 +185,8 @@ function binToFile(bin, options = {}) {
187185
}
188186
}
189187

190-
file = file.split('^^hash^^').join(hashOf(file));
188+
// no longer used
189+
// file = file.split('^^hash^^').join(hashOf(file));
191190

192191
return file;
193192
}

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bin-to-file",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Converts JS Bin object to static HTML",
55
"main": "lib/index.js",
66
"directories": {
@@ -14,9 +14,7 @@
1414
"type": "git",
1515
"url": "git://github.com/jsbin/bin-to-file.git"
1616
},
17-
"keywords": [
18-
"jsbin"
19-
],
17+
"keywords": ["jsbin"],
2018
"author": "Remy Sharp",
2119
"bugs": {
2220
"url": "https://github.com/jsbin/bin-to-file/issues"

0 commit comments

Comments
 (0)