Files
eruda/src/Network/util.js
2018-01-02 16:54:31 +08:00

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);
}