File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -127,29 +127,25 @@ function missingTag(tag) {
127127
128128function insertIntoIndexHTML ( html , head , body ) {
129129 if ( ! html ) { return Promise . resolve ( html ) ; }
130+ let isBodyReplaced = false ;
131+ let isHeadReplaced = false ;
130132
131- if ( body ) {
132- let isBodyReplaced = false ;
133- html = html . replace ( "<!-- EMBER_CLI_FASTBOOT_BODY -->" , function ( ) {
133+ html = html . replace ( / < \! - - E M B E R _ C L I _ F A S T B O O T _ ( H E A D | B O D Y ) - - > / g, function ( match , tag ) {
134+ if ( tag === 'HEAD' && head && ! isHeadReplaced ) {
135+ isHeadReplaced = true ;
136+ return head ;
137+ } else if ( tag === 'BODY' && body && ! isBodyReplaced ) {
134138 isBodyReplaced = true ;
135139 return body ;
136- } ) ;
137-
138- if ( ! isBodyReplaced ) {
139- return missingTag ( '<!--EMBER_CLI_FASTBOTT_BODY-->' ) ;
140140 }
141- }
141+ return '' ;
142+ } ) ;
142143
143- if ( head ) {
144- let isHeadReplaced = false ;
145- html = html . replace ( "<!-- EMBER_CLI_FASTBOOT_HEAD -->" , function ( ) {
146- isHeadReplaced = true ;
147- return head ;
148- } ) ;
149-
150- if ( ! isHeadReplaced ) {
151- return missingTag ( '<!--EMBER_CLI_FASTBOTT_HEAD-->' ) ;
152- }
144+ if ( head && ! isHeadReplaced ) {
145+ return missingTag ( '<!--EMBER_CLI_FASTBOOT_HEAD-->' ) ;
146+ }
147+ if ( body && ! isBodyReplaced ) {
148+ return missingTag ( '<!--EMBER_CLI_FASTBOOT_BODY-->' ) ;
153149 }
154150
155151 return Promise . resolve ( html ) ;
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ describe('Result', function() {
3939 return result . html ( )
4040 . catch ( function ( e ) {
4141 expect ( e ) . to . be . an ( 'error' ) ;
42- expect ( e . message ) . to . equal ( "Fastboot was not able to find <!--EMBER_CLI_FASTBOTT_BODY --> in base HTML. It could not replace the contents." ) ;
42+ expect ( e . message ) . to . equal ( "Fastboot was not able to find <!--EMBER_CLI_FASTBOOT_BODY --> in base HTML. It could not replace the contents." ) ;
4343 done ( ) ;
4444 } ) ;
4545 } ) ;
@@ -55,7 +55,7 @@ describe('Result', function() {
5555 return result . html ( )
5656 . catch ( function ( e ) {
5757 expect ( e ) . to . be . an ( 'error' ) ;
58- expect ( e . message ) . to . equal ( "Fastboot was not able to find <!--EMBER_CLI_FASTBOTT_HEAD --> in base HTML. It could not replace the contents." ) ;
58+ expect ( e . message ) . to . equal ( "Fastboot was not able to find <!--EMBER_CLI_FASTBOOT_HEAD --> in base HTML. It could not replace the contents." ) ;
5959 done ( ) ;
6060 } ) ;
6161 } ) ;
You can’t perform that action at this time.
0 commit comments