mirror of https://github.com/casbin/casnode.git
Fix uppercase file suffix bug
Signed-off-by: kocoler <tsglsdrs@163.com>
This commit is contained in:
parent
c56c50bc0c
commit
7e76e982ca
|
@ -35,10 +35,13 @@ func FileType(fileName string) string {
|
|||
return "file"
|
||||
}
|
||||
|
||||
lowerCase := strings.ToLower(ext)
|
||||
|
||||
for _, v := range stdImageExt {
|
||||
if v == ext {
|
||||
if v == lowerCase {
|
||||
return "image"
|
||||
}
|
||||
}
|
||||
|
||||
return "file"
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ export function initNewOSSClient(accessKeyId, accessKeySecret, stsToken) {
|
|||
export function initOSSClient(id) {
|
||||
getOSSClient(initNewOSSClient);
|
||||
let url, fileUrl;
|
||||
id = encodeURI(id);
|
||||
//id = encodeURI(id);
|
||||
if (Conf.OSSCustomDomain.length !== 0) {
|
||||
url = `https://${Conf.OSSCustomDomain}/${Conf.OSSBasicPath}/${id}`;
|
||||
} else {
|
||||
|
@ -248,7 +248,8 @@ export function getFileType(fileName) {
|
|||
let fileType = "image";
|
||||
let fileIndex = fileName.lastIndexOf(".");
|
||||
let ext = fileName.substr(fileIndex+1);
|
||||
let index = stdImageExt.indexOf(ext);
|
||||
let lowerCase = ext.toLowerCase();
|
||||
let index = stdImageExt.indexOf(lowerCase);
|
||||
if(index < 0) {
|
||||
fileType = "file";
|
||||
}
|
||||
|
|
|
@ -28,10 +28,11 @@ export function uploadMdFile(addMsg) {
|
|||
const stdImageExt = ["png", "jpg", "gif", "jpeg"]
|
||||
/* eslint-disable */inlineAttachment.prototype.onFileUploadResponse = function(fileName, fileUrl) {
|
||||
let newValue = this.settings.urlText.replace('file', fileName);
|
||||
let fileIndex = fileName.lastIndexOf("."); // find the ext of the file, choosing []() or ![]()
|
||||
let ext = fileName.substr(fileIndex+1);
|
||||
let index = stdImageExt.indexOf(ext);
|
||||
if(index < 0) {
|
||||
let fileType = Setting.getFileType(fileName); // find the ext of the file, choosing []() or ![]()
|
||||
//let fileIndex = fileName.lastIndexOf(".");
|
||||
//let ext = fileName.substr(fileIndex+1);
|
||||
//let index = stdImageExt.indexOf(ext);
|
||||
if(fileType.fileType === "file") {
|
||||
newValue = newValue.substring(1);
|
||||
}
|
||||
newValue = newValue.replace('{filename}', fileUrl)
|
||||
|
|
Loading…
Reference in New Issue