summaryrefslogtreecommitdiffstats
path: root/web/path.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/path.js')
-rw-r--r--web/path.js32
1 files changed, 27 insertions, 5 deletions
diff --git a/web/path.js b/web/path.js
index bb60c76..2373867 100644
--- a/web/path.js
+++ b/web/path.js
@@ -6,12 +6,34 @@
define(["underscore"], function(_) {
function split(path) {
var res = [];
- while (path && path != "/") {
- var comp = path.match(/^\/([^\\\/]|\\.)+/)[0];
- res.push(comp.substring(1));
- path = path.substring(comp.length);
+ var comp = "";
+ var escaped;
+
+ function merge(s) {
+ var n = Number(s);
+ if (s > "") res.push((escaped || isNaN) ? s : n);
+ }
+
+ while (true) {
+ var m = path.match(/^([^\\\/]*)([\\\/])(.*)/);
+ if (!m) {
+ merge(comp + path);
+ return res;
+ }
+
+ comp += m[1];
+ if (m[2] == "\\") {
+ comp += m[3].substring(0, 1);
+ escaped = true;
+ path = m[3].substring(1);
+ }
+ else {
+ merge(comp);
+ comp = "";
+ escaped = false;
+ path = m[3];
+ }
}
- return res;
}
function escape(name) {