-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX Strip html tags from file upload error responses
- Loading branch information
1 parent
88dadaf
commit 33b0003
Showing
10 changed files
with
57 additions
and
12 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,13 @@ | ||
import i18n from 'i18n'; | ||
|
||
/** | ||
* Convert an http status code to a message | ||
* | ||
* @param { int } statusCode | ||
*/ | ||
export default function getStatusCodeMessage(statusCode) { | ||
if (statusCode === 413) { | ||
return i18n._t('AssetAdmin.ERROR_FILE_SIZE', 'File size limit exceeded'); | ||
} | ||
return i18n._t('AssetAdmin.ERROR_DEFAULT', 'Something went wrong, please try again'); | ||
} |
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,14 @@ | ||
/* global jest, jasmine, describe, it, expect, beforeEach, FormData */ | ||
|
||
import getStatusCodeMessage from '../getStatusCodeMessage'; | ||
|
||
describe('getStatusCodeMessage', () => { | ||
const defaultMessage = getStatusCodeMessage(999); | ||
it('Has a default message', () => { | ||
expect(defaultMessage.length > 0).toBe(true); | ||
}); | ||
it('To have a different message for a 413 status code', () => { | ||
const status413Message = getStatusCodeMessage(413); | ||
expect(status413Message.length > 0 && status413Message !== defaultMessage).toBe(true); | ||
}); | ||
}); |
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