Skip to content

Commit

Permalink
Improvements to m2 store detection (#52)
Browse files Browse the repository at this point in the history
## This PR is a:

- [ ] New feature
- [ ] Enhancement/Optimization
- [ ] Refactor
- [X] Bugfix
- [ ] Test for existing code
- [ ] Documentation

## Summary

When this pull request is merged, it will make the extension work for stores with signed static files disabled and the RequireJS static head block moved to the body.

## Additional information
  • Loading branch information
DrewML committed Dec 23, 2018
1 parent e31c423 commit 81ca5dc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions extension/devtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ function onPanelShown(panel) {
});
}

/**
* Needs to handle
* - Stores with signing of static files disabled
* - Stores with the RequireJS head block moved to the body
* - Stores with Magento's built-in minification enabled
*/
function isMagento2Store() {
const reRequireScript = /\/static\/version\d+\/frontend\/.+\/.+\/requirejs\/require(?:\.min)?\.js/;
const scripts = Array.from(document.querySelectorAll('head > script[src]') || []);
const reRequireScript = /\/static(?:\/version\d+)?\/frontend\/.+\/.+\/requirejs\/require(?:\.min)?\.js/;
const scripts = Array.from(document.querySelectorAll('script[src]') || []);
return scripts.some(s => reRequireScript.test(s.src));
}

Expand Down

0 comments on commit 81ca5dc

Please sign in to comment.