Permalink
Browse files

Update mass.js

优化 相对于父路径 的转换逻辑
  • Loading branch information...
RubyLouvre committed Feb 10, 2014
1 parent 86bf488 commit 5a69301721cb90ffded61fd6dccff7e9f9ddb1c9
Showing with 5 additions and 7 deletions.
  1. +5 −7 mass.js
View
12 mass.js
@@ -436,7 +436,7 @@ void function(global, DOC) {
return true;
}
}
-
+ var rdeuce = /\/\w+\/\.\./
function loadJSCSS(url, parent, ret, shim) {
//1. 特别处理mass|ready标识符
if (/^(mass|ready)$/.test(url)) {
@@ -460,12 +460,10 @@ void function(global, DOC) {
} else if (url.slice(0, 2) === "./") { //相对于兄弟路径
ret = parent + url.slice(1);
} else if (url.slice(0, 2) === "..") { //相对于父路径
- var arr = parent.replace(/\/$/, "").split("/");
- tmp = url.replace(/\.\.\//g, function() {
- arr.pop();
- return "";
- });
- ret = arr.join("/") + "/" + tmp;
+ ret = parent + "/" + url
+ while (rdeuce.test(ret)) {
+ ret = ret.replace(rdeuce, "")
+ }
} else if (tmp === "/") {
ret = parent + url;//相对于兄弟路径
} else {

0 comments on commit 5a69301

Please sign in to comment.