2024-01-22 06:35:32 +08:00
|
|
|
import { AbstractCollectionModel } from 'Model/AbstractCollection';
|
|
|
|
import { MimeHeaderModel } from 'Model/MimeHeader';
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
export class MimeHeaderCollectionModel extends AbstractCollectionModel
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param {?Array} json
|
|
|
|
* @returns {MimeHeaderCollectionModel}
|
|
|
|
*/
|
|
|
|
static reviveFromJson(items) {
|
|
|
|
return super.reviveFromJson(items, header => MimeHeaderModel.reviveFromJson(header));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {string} name
|
|
|
|
* @returns {?MimeHeader}
|
|
|
|
*/
|
|
|
|
getByName(name)
|
|
|
|
{
|
|
|
|
name = name.toLowerCase();
|
|
|
|
return this.find(header => header.name.toLowerCase() === name);
|
|
|
|
}
|
|
|
|
|
|
|
|
valueByName(name)
|
|
|
|
{
|
|
|
|
const header = this.getByName(name);
|
|
|
|
return header ? header.value : '';
|
|
|
|
}
|
|
|
|
|
2024-02-12 08:01:19 +08:00
|
|
|
valuesByName(name)
|
|
|
|
{
|
|
|
|
name = name.toLowerCase();
|
|
|
|
return this.filter(header => header.name.toLowerCase() === name).map(header => header.value);
|
|
|
|
}
|
|
|
|
|
2024-01-22 06:35:32 +08:00
|
|
|
}
|