This repository has been archived by the owner on May 28, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a button on Pepite home page to extract applications in xls file
- Loading branch information
Showing
6 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export function getFilename(header) { | ||
const re = /.*filename=['"](.*)['"].*/ | ||
const match = header.match(re) | ||
if (match && match.length == 2) { | ||
return match[1] | ||
} else { | ||
return null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import expect from 'expect' | ||
import { getFilename } from './requestUtils' | ||
|
||
|
||
describe('requestUtils', () => { | ||
describe('getFilename', () => { | ||
it('should return the fileaname in a Content-Disposition header', () => { | ||
const filename = 'data.xls' | ||
const contentDispostionHeader = `attachment; filename="${filename}"` | ||
expect(getFilename(contentDispostionHeader)).toBe(filename) | ||
}) | ||
it('should return null otherwise', () => { | ||
const filename = 'data.xls' | ||
const badContentDispostionHeader = `attachment; filenamebad="${filename}"` | ||
expect(getFilename(badContentDispostionHeader)).toBe(null) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters