Skip to content

Commit

Permalink
Respect require paths
Browse files Browse the repository at this point in the history
  • Loading branch information
javalikescript committed Jan 18, 2025
1 parent 60f435f commit 77e6d6e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions extensions/web-base/www/amdimpl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Asynchronous Module Definition (AMD) API implementation for JLS.
* The following code creates a 'require' function to load modules.
* See https://github.com/amdjs/amdjs-api
*/
(function() {
/* Helper functions */
Expand All @@ -22,6 +23,12 @@
var index = path.lastIndexOf('/');
return index === -1 ? '' : path.substring(0, index);
}
function endsWith(value, search) {
return value.substring(value.length - search.length) === search;
}
function startsWith(value, search) {
return value.substring(0, search.length) === search;
}
function concatPath(a, b) {
var pathItems = b.split('/');
if ((a !== '.') && ((pathItems[0] === '.') || (pathItems[0] === '..'))) {
Expand All @@ -37,7 +44,14 @@
i -= 2;
}
}
return pathItems.join('/');
var path = pathItems.join('/');
if (startsWith(b, '/')) {
path = '/' + path;
}
if (endsWith(b, '/')) {
path = path + '/';
}
return path;
}
function basemodule(path) {
var index = path.indexOf('$');
Expand Down Expand Up @@ -171,7 +185,7 @@
var self = this;
var path = this.path;
var ext = extension(path);
if (ext === '') {
if (ext === '' && !endsWith(path, '/')) {
path += '.js';
}
this.loading = true;
Expand Down

0 comments on commit 77e6d6e

Please sign in to comment.