Model can't open if an url parameter contains slash #351
This commit is contained in:
parent
c2e41d1e0b
commit
ff05887daa
@ -20,18 +20,21 @@ export const FileFormat =
|
||||
|
||||
export function GetFileName (filePath)
|
||||
{
|
||||
let firstSeparator = filePath.lastIndexOf ('/');
|
||||
if (firstSeparator === -1) {
|
||||
firstSeparator = filePath.lastIndexOf ('\\');
|
||||
}
|
||||
let fileName = filePath;
|
||||
if (firstSeparator !== -1) {
|
||||
fileName = filePath.substring (firstSeparator + 1);
|
||||
}
|
||||
|
||||
let firstParamIndex = fileName.indexOf ('?');
|
||||
if (firstParamIndex !== -1) {
|
||||
fileName = fileName.substring (0, firstParamIndex);
|
||||
}
|
||||
|
||||
let firstSeparator = fileName.lastIndexOf ('/');
|
||||
if (firstSeparator === -1) {
|
||||
firstSeparator = fileName.lastIndexOf ('\\');
|
||||
}
|
||||
if (firstSeparator !== -1) {
|
||||
fileName = fileName.substring (firstSeparator + 1);
|
||||
}
|
||||
|
||||
return decodeURI (fileName);
|
||||
}
|
||||
|
||||
|
||||
@ -30,6 +30,8 @@ describe ('File Utils', function () {
|
||||
assert.strictEqual (OV.GetFileName ('folder\\file'), 'file');
|
||||
assert.strictEqual (OV.GetFileName ('folder\\file.obj'), 'file.obj');
|
||||
assert.strictEqual (OV.GetFileName ('folder\\file.OBJ'), 'file.OBJ');
|
||||
assert.strictEqual (OV.GetFileName ('file.obj?a=b&c=d'), 'file.obj');
|
||||
assert.strictEqual (OV.GetFileName ('file.obj?param=a/b/c'), 'file.obj');
|
||||
});
|
||||
|
||||
it ('Read Lines', function () {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user