forked from mei23/misskey-v11
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: drive/files 系の type の validater Fix #2386
- Loading branch information
Showing
4 changed files
with
61 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const typeFilterValidater = /^([a-z]+)[/]([*]|[0-9A-Za-z+.-]+)$/; |
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,56 @@ | ||
import * as assert from 'assert'; | ||
import { typeFilterValidater } from '../src/misc/mime-type-filter'; | ||
|
||
describe('typeFilterValidater', () => { | ||
it('Allow image/jpeg', () => { | ||
assert.strictEqual(typeFilterValidater.test('image/jpeg'), true); | ||
}); | ||
|
||
it('Allow image/*', () => { | ||
assert.strictEqual(typeFilterValidater.test('image/*'), true); | ||
}); | ||
|
||
it('Reject image/a*', () => { | ||
assert.strictEqual(typeFilterValidater.test('image/a*'), false); | ||
}); | ||
|
||
it('Reject image/a*b*c', () => { | ||
assert.strictEqual(typeFilterValidater.test('image/a*b*c'), false); | ||
}); | ||
|
||
it('Reject image*/jpeg', () => { | ||
assert.strictEqual(typeFilterValidater.test('image*/jpeg'), false); | ||
}); | ||
|
||
it('Reject image/*/*', () => { | ||
assert.strictEqual(typeFilterValidater.test('image/*/*'), false); | ||
}); | ||
|
||
it('Allow video/mp4', () => { | ||
assert.strictEqual(typeFilterValidater.test('video/mp4'), true); | ||
}); | ||
|
||
it('Allow video/MP1S', () => { | ||
assert.strictEqual(typeFilterValidater.test('video/MP1S'), true); | ||
}); | ||
|
||
it('Allow image/x-icon', () => { | ||
assert.strictEqual(typeFilterValidater.test('image/x-icon'), true); | ||
}); | ||
|
||
it('Allow image/svg+xml', () => { | ||
assert.strictEqual(typeFilterValidater.test('image/svg+xml'), true); | ||
}); | ||
|
||
it('Allow audio/vnd.wave', () => { | ||
assert.strictEqual(typeFilterValidater.test('audio/vnd.wave'), true); | ||
}); | ||
|
||
it('Reject %', () => { | ||
assert.strictEqual(typeFilterValidater.test('image/%'), false); | ||
}); | ||
|
||
it('Reject _', () => { | ||
assert.strictEqual(typeFilterValidater.test('image/_'), false); | ||
}); | ||
}); |