Skip to content

Commit

Permalink
more robust detection of baseUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
nightwing committed Mar 2, 2023
1 parent 60a4c5c commit c4ef403
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/ace/loader_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ function init(packaged) {
var currentScript = (document.currentScript || document._currentScript ); // native or polyfill
var currentDocument = currentScript && currentScript.ownerDocument || document;

if (currentScript && currentScript.src) {
scriptUrl = currentScript.src.split(/[?#]/)[0].split("/").slice(0, -1).join("/") || "";
}

var scripts = currentDocument.getElementsByTagName("script");
for (var i=0; i<scripts.length; i++) {
var script = scripts[i];
Expand All @@ -59,7 +63,7 @@ function init(packaged) {
}
}

var m = src.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/);
var m = src.match(/^(.*)\/ace([\-.]\w+)?\.js(\?|$)/);
if (m)
scriptUrl = m[1];
}
Expand Down

0 comments on commit c4ef403

Please sign in to comment.