1
- var doctypeRe = new RegExp ( / ^ < ! d o c t y p e [ ^ > ] * > \n ? / im) ;
1
+ const doctypeRe = new RegExp ( / ^ < ! d o c t y p e [ ^ > ] * > \n ? / im) ;
2
2
3
3
function hashOf ( string ) {
4
4
let hash = 0 ;
@@ -60,14 +60,12 @@ function binToFile(bin, options = {}) {
60
60
let meta =
61
61
bin . meta ||
62
62
( bin . url
63
- ? `<!-- source: http ://jsbin.com/${ bin . url } /${ bin . revision || '' } -->\n`
63
+ ? `<!-- source: https ://jsbin.com/${ bin . url } /${ bin . revision || '' } -->\n`
64
64
: '' ) ;
65
65
66
66
// insert protocol if missing
67
67
html = html . replace ( / ( s r c | h r e f ) = ( ' | " ) \/ \/ / g, '$1=$2' + proto + '//' ) ;
68
68
69
- // meta = meta + '<!--hash:' + bin.url + '/' + bin.revision + '/^^hash^^-->\n';
70
-
71
69
if ( meta && meta . slice ( - 1 ) !== '\n' ) {
72
70
meta += '\n' ; // a nice new line for the meta data
73
71
}
@@ -98,8 +96,8 @@ function binToFile(bin, options = {}) {
98
96
file = file . split ( '%css%' ) . join ( bin . css ) ;
99
97
} else {
100
98
// 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 ) ;
103
101
if ( head ) {
104
102
file = head ;
105
103
} else {
@@ -124,7 +122,7 @@ function binToFile(bin, options = {}) {
124
122
. match ( doctypeRe ) || [ ] ) [ 0 ] || '' ;
125
123
126
124
if ( doctype ) {
127
- file = file . replace ( doctypeRe , doctype + '\n' + meta ) ;
125
+ file = file . replace ( doctypeRe , ` ${ doctype } \n ${ meta } ` ) ;
128
126
// strip from original html
129
127
} else {
130
128
file = meta + file ;
@@ -143,7 +141,7 @@ function binToFile(bin, options = {}) {
143
141
file = body ;
144
142
} else {
145
143
// slap on the bottom
146
- file = file + '\n' + javascript ;
144
+ file = ` ${ file } \n ${ javascript } ` ;
147
145
}
148
146
}
149
147
}
@@ -187,7 +185,8 @@ function binToFile(bin, options = {}) {
187
185
}
188
186
}
189
187
190
- file = file . split ( '^^hash^^' ) . join ( hashOf ( file ) ) ;
188
+ // no longer used
189
+ // file = file.split('^^hash^^').join(hashOf(file));
191
190
192
191
return file ;
193
192
}
0 commit comments