mirror of
https://github.com/liriliri/eruda.git
synced 2026-03-24 09:48:37 +08:00
20 lines
387 B
JavaScript
20 lines
387 B
JavaScript
import util from '../lib/util';
|
|
|
|
export function getType(contentType)
|
|
{
|
|
if (!contentType) return 'unknown';
|
|
|
|
let type = contentType.split(';')[0].split('/');
|
|
|
|
return {
|
|
type: type[0],
|
|
subType: util.last(type)
|
|
};
|
|
}
|
|
|
|
export function lenToUtf8Bytes(str)
|
|
{
|
|
let m = encodeURIComponent(str).match(/%[89ABab]/g);
|
|
|
|
return str.length + (m ? m.length : 0);
|
|
} |