Skip to content

Commit d04e3ba

Browse files
committed
v0.3.0
fix some typos add absolute path support
1 parent c652064 commit d04e3ba

File tree

6 files changed

+23
-17
lines changed

6 files changed

+23
-17
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/node_modules/
1+
/node_modules/

Gruntfile.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,4 @@ module.exports = function(grunt) {
5252
// Define tasks
5353
grunt.registerTask('test', ['Server', 'jshint', 'qunit']);
5454
grunt.registerTask('minify', ['jshint', 'clean', 'uglify']);
55-
5655
};

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Scriptrjs",
33
"main": "scriptr.js",
4-
"version": "0.2.0",
4+
"version": "0.3.0",
55
"description": "Simple AMD Module Loader",
66
"moduleType": [
77
"AMD"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Scriptrjs",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"keywords": [
55
"loader",
66
"require",

scriptr-0.2.0.min.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

scriptr.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(function () {
22
"use strict";
3-
3+
44
var doc = window.document,
55
head = doc.getElementsByTagName('head')[0],
66
a = doc.createElement("a"); //for resolving urls
@@ -14,7 +14,7 @@
1414
path = script_tags[script_tags.length - 1].src;
1515
path = path.match(/(.*\/).*\.js/);
1616
return path[1];
17-
})(), Clobal_Path = SELF_URL;
17+
})(), Global_Path = SELF_URL;
1818

1919
function isArray (obj) {
2020
return Object.prototype.toString.call(obj) === "[object Array]";
@@ -25,9 +25,17 @@
2525
return false;
2626
}
2727

28-
function resolveUri (uri) {
28+
function resolveUri (uri, parent) {
29+
var fullURI;
30+
31+
if (uri.indexOf('/') === 0){
32+
fullURI = uri;
33+
} else {
34+
fullURI = parent + uri;
35+
}
36+
2937
var resolved;
30-
a.href = uri;
38+
a.href = fullURI;
3139
resolved = a.href;
3240
return resolved;
3341
}
@@ -68,17 +76,17 @@
6876
request = request.file;
6977
}
7078

71-
if (!isURL(request)) { path = Clobal_Path; }
79+
if (!isURL(request)) { path = Global_Path; }
7280
} else if (isURL(request)) {
7381
//nothing to do
7482
} else if (parent && parent.id) {
75-
path = resolveUri(parent.id + '/../');
83+
path = resolveUri('./../', parent.id);
7684
} else {
77-
path = Clobal_Path;
85+
path = Global_Path;
7886
}
79-
87+
8088
return {
81-
file : resolveUri(path + request),
89+
file : resolveUri(request, path),
8290
imports : _imports
8391
};
8492
};
@@ -265,10 +273,10 @@
265273
};
266274

267275
require.Path = function (path) {
268-
var old = Clobal_Path;
276+
var old = Global_Path;
269277
var self_path = isURL(path) ? '' : SELF_URL;
270-
Clobal_Path = resolveUri(self_path + path);
271-
debug("PATH: Change Global Path From " + old + " to " + Clobal_Path);
278+
Global_Path = resolveUri(path, self_path);
279+
debug("PATH: Change Global Path From " + old + " to " + Global_Path);
272280
};
273281

274282
require.debug = false;

0 commit comments

Comments
 (0)