Browse Source

Merge pull request #717 from herby/detect-bower

Detect if amber is really included as bower package.
Nicolas Petton 10 years ago
parent
commit
4960f41eb4
1 changed files with 10 additions and 0 deletions
  1. 10 0
      support/amber.js

+ 10 - 0
support/amber.js

@@ -24,6 +24,16 @@ require = function (require) {
     // e.g. http://app.com/index.html -> http://app.com/
     var document_home = window.location.href.replace(/\/[^\/]+$/, "");
 
+    // at the present moment, bower tries to have flat hierarchy,
+    // which leads to two possible scenarios:
+    // 1. amber itself was deployed via bower,
+    //    its libraries are next to it; document_home from above covers this
+    // 2. amber was deployed in different fashion,
+    //    its libraries are included by bower locally; document_home is fixed below
+    // The detection is done by looking for '/bower_components/' in amber path.
+    if (!amber_home.match(/\/bower_components\//)) {
+        document_home = amber_home;
+    }
 
     function resolveViaDOM(url) {
         var a = document.createElement("a");