ocombe / ocLazyLoad

Lazy load modules & components in AngularJS
https://oclazyload.readme.io
MIT License
2.63k stars 510 forks source link

preceding type declaration can not detect whether cached #299

Open spnettec opened 8 years ago

spnettec commented 8 years ago

changes like this: if (angular.isObject(path)) { file_type = path.type; path = path.path; } cachePromise = filesCache.get(path); if (angular.isUndefined(cachePromise) || params.cache === false) {

                    // always check for requirejs syntax just in case
                    if ((m = /^(css|less|html|htm|js)?(?=!)/.exec(path)) !== null) {
                        // Detect file type using preceding type declaration (ala requireJS)
                        file_type = m[1];
                        path = path.substr(m[1].length + 1, path.length); // Strip the type from the path
                    }

                    if (!file_type) {
                        if ((m = /[.](css|less|html|htm|js)?((\?|#).*)?$/.exec(path)) !== null) {
                            // Detect file type via file extension
                            file_type = m[1];
                        } else if (!$delegate.jsLoader.hasOwnProperty('ocLazyLoadLoader') && $delegate.jsLoader.hasOwnProperty('requirejs')) {
                            // requirejs
                            file_type = 'js';
                        } else {
                            $delegate._$log.error('File type could not be determined. ' + path);
                            return;
                        }
                    }

to:

if (angular.isObject(path)) { file_type = path.type; path = path.path; } // always check for requirejs syntax just in case if ((m = /^(css|less|html|htm|js)?(?=!)/.exec(path)) !== null) { // Detect file type using preceding type declaration (ala requireJS) file_type = m[1]; path = path.substr(m[1].length + 1, path.length); // Strip the type from the path } cachePromise = filesCache.get(path); if (angular.isUndefined(cachePromise) || params.cache === false) {

                    if (!file_type) {
                        if ((m = /[.](css|less|html|htm|js)?((\?|#).*)?$/.exec(path)) !== null) {
                            // Detect file type via file extension
                            file_type = m[1];
                        } else if (!$delegate.jsLoader.hasOwnProperty('ocLazyLoadLoader') && $delegate.jsLoader.hasOwnProperty('requirejs')) {
                            // requirejs
                            file_type = 'js';
                        } else {
                            $delegate._$log.error('File type could not be determined. ' + path);
                            return;
                        }
                    }

will resove this problem