Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chenwenxiao committed Feb 22, 2019
1 parent f4bdbee commit eaa82b8
Showing 1 changed file with 17 additions and 25 deletions.
42 changes: 17 additions & 25 deletions assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,22 @@ function getQueryString(name) {
return null;
}

function checkPathnameLegal(name) {
function checkPathNameLegal(name) {
var reg = new RegExp("[\\/:*<>|]");
var r = name.match(reg)
return r == null;
}

function showErrorMessage(jqXHR) {
let errMsg = jqXHR.getResponseHeader("x-auth-authentication-message")
if (errMsg == null) {
errMsg = jqXHR.responseText
}
alert(String(jqXHR.status).concat(":", errMsg));
console.error(errMsg)
}


var vm = new Vue({
el: "#app",
data: {
Expand Down Expand Up @@ -251,12 +261,7 @@ var vm = new Vue({
// console.log(JSON.stringify(res, null, 4));
},
error: function (jqXHR, textStatus, errorThrown) {
let errMsg = jqXHR.getResponseHeader("x-auth-authentication-message")
if (errMsg == null) {
errMsg = jqXHR.statusText
}
alert(String(jqXHR.status).concat(":", errMsg));
console.error(errMsg)
showErrorMessage(jqXHR)
}
})
},
Expand All @@ -266,7 +271,7 @@ var vm = new Vue({
if (!name) {
return
}
if(!checkPathnameLegal(name)) {
if(!checkPathNameLegal(name)) {
alert("Name should not contains any of \\/:*<>|")
return
}
Expand All @@ -281,11 +286,7 @@ var vm = new Vue({
loadFileList()
},
error: function (jqXHR, textStatus, errorThrown) {
let errMsg = jqXHR.getResponseHeader("x-auth-authentication-message")
if (errMsg == null) {
errMsg = jqXHR.responseText
}
alert(String(jqXHR.status).concat(":", errMsg));
showErrorMessage(jqXHR)
}
})
},
Expand All @@ -303,11 +304,7 @@ var vm = new Vue({
loadFileList()
},
error: function (jqXHR, textStatus, errorThrown) {
let errMsg = jqXHR.getResponseHeader("x-auth-authentication-message")
if (errMsg == null) {
errMsg = jqXHR.responseText
}
alert(String(jqXHR.status).concat(":", errMsg));
showErrorMessage(jqXHR)
}
});
},
Expand Down Expand Up @@ -376,7 +373,7 @@ function loadFileOrDir(reqPath) {
var retObj = loadFileList(requestUri)
if(retObj !== null) {
retObj.done(function (value) {
window.history.pushState({}, "", requestUri);
window.history.pushState({}, "", requestUri);
});
}

Expand All @@ -401,12 +398,7 @@ function loadFileList(pathname) {
vm.updateBreadcrumb(pathname);
},
error: function (jqXHR, textStatus, errorThrown) {
let errMsg = jqXHR.getResponseHeader("x-auth-authentication-message")
if(errMsg == null){
errMsg = jqXHR.responseText
}
alert(String(jqXHR.status).concat(":", errMsg));
console.error(errMsg)
showErrorMessage(jqXHR)
},
});

Expand Down

0 comments on commit eaa82b8

Please sign in to comment.