Skip to content

Commit

Permalink
[Bug]: general match for nonce script across versions of ember-cli (#201
Browse files Browse the repository at this point in the history
)
  • Loading branch information
snewcomer authored May 6, 2021
1 parent 9332dcc commit 759e425
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,21 +296,10 @@ module.exports = {

// Add nonce to <script> tag inserted by Ember CLI to assert that test file was loaded.
if (type === 'test-body-footer') {
let emberCliDependency = new VersionChecker(this.project).for(
'ember-cli'
);

existingContent.forEach((entry, index) => {
let result;
if (emberCliDependency.exists() && emberCliDependency.lt('3.25.1')) {
result = /<script>\s*Ember.assert\(.*EmberENV.TESTS_FILE_LOADED\);\s*<\/script>/.test(
entry
);
} else {
result = /<script>.*?Ember\.assert\(.*EmberENV\.TESTS_FILE_LOADED\);\s*}\);<\/script>/.test(
entry
);
}
let result = /<script>[\s\S]*?'The tests file was not loaded\. Make sure your tests index\.html includes "assets\/tests\.js"\.'[\s\S]*?<\/script>/.test(
entry
);

if (result) {
existingContent[index] = entry.replace(
Expand Down

0 comments on commit 759e425

Please sign in to comment.