extract and test regexp that identifies angular script tag

This commit is contained in:
Igor Minar
2010-10-19 17:07:20 -07:00
parent 2115db6903
commit 644c8514c5
2 changed files with 72 additions and 4 deletions

View File

@@ -48,7 +48,8 @@ var _undefined = undefined,
angularFormatter = extensionMap(angular, 'formatter'),
angularService = extensionMap(angular, 'service'),
angularCallbacks = extensionMap(angular, 'callbacks'),
nodeName;
nodeName,
rngScript = /^(|.*\/)angular(-.*)?(\.min)?.js(\?[^#]*)?(#(.*))?$/;
function foreach(obj, iterator, context) {
var key;
@@ -422,8 +423,7 @@ function angularInit(config){
}
function angularJsConfig(document, config) {
var filename = /^(.*)angular(-([^\/]*))?.js(\?[^#]*)?(#(.*))?$/,
scripts = document.getElementsByTagName("script"),
var scripts = document.getElementsByTagName("script"),
match;
config = extend({
base_url: '',
@@ -431,7 +431,7 @@ function angularJsConfig(document, config) {
ie_compat_id: 'ng-ie-compat'
}, config);
for(var j = 0; j < scripts.length; j++) {
match = (scripts[j].src || "").match(filename);
match = (scripts[j].src || "").match(rngScript);
if (match) {
config.base_url = match[1];
extend(config, parseKeyValue(match[6]));