improve(tio): extract file name from Content-Disposition (#4035)
* Added extraction of quoted file name from content disposition header * Added extraction of quoted file name from content disposition header - PR Fixes * Added extraction of quoted file name from content disposition header - PR Fixes * Added extraction of quoted file name from content disposition header - PR Fixes
This commit is contained in:
@@ -18,7 +18,8 @@ import {
|
||||
getAcceptControllingResponse,
|
||||
createDeepLinkPath,
|
||||
escapeDeepLinkPath,
|
||||
sanitizeUrl
|
||||
sanitizeUrl,
|
||||
extractFileNameFromContentDispositionHeader
|
||||
} from "core/utils"
|
||||
import win from "core/window"
|
||||
|
||||
@@ -90,6 +91,26 @@ describe("utils", function() {
|
||||
|
||||
})
|
||||
|
||||
describe("extractFileNameFromContentDispositionHeader", function(){
|
||||
it("should extract quoted filename", function(){
|
||||
let cdHeader = "attachment; filename=\"file name.jpg\""
|
||||
let expectedResult = "file name.jpg"
|
||||
expect(extractFileNameFromContentDispositionHeader(cdHeader)).toEqual(expectedResult)
|
||||
})
|
||||
|
||||
it("should extract filename", function(){
|
||||
let cdHeader = "attachment; filename=filename.jpg"
|
||||
let expectedResult = "filename.jpg"
|
||||
expect(extractFileNameFromContentDispositionHeader(cdHeader)).toEqual(expectedResult)
|
||||
})
|
||||
|
||||
it("should not extract filename and return null", function(){
|
||||
let cdHeader = "attachment; no file name provided"
|
||||
let expectedResult = null
|
||||
expect(extractFileNameFromContentDispositionHeader(cdHeader)).toEqual(expectedResult)
|
||||
})
|
||||
})
|
||||
|
||||
describe("validateMaximum", function() {
|
||||
let errorMessage = "Value must be less than Maximum"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user