31 lines
1.3 KiB
JavaScript
31 lines
1.3 KiB
JavaScript
|
"use strict";
|
||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||
|
};
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
const resource_processor_base_1 = __importDefault(require("./resource-processor-base"));
|
||
|
class ManifestProcessor extends resource_processor_base_1.default {
|
||
|
processResource(manifest, _ctx, _charset, urlReplacer) {
|
||
|
const lines = manifest.split('\n');
|
||
|
for (let i = 0; i < lines.length; i++) {
|
||
|
const line = lines[i].trim();
|
||
|
if (line && line !== 'CACHE MANIFEST' && line !== 'NETWORK:' && line !== 'FALLBACK:' &&
|
||
|
line !== 'CACHE:' && line[0] !== '#' && line !== '*') {
|
||
|
const isFallbackItem = line.includes(' ');
|
||
|
if (isFallbackItem) {
|
||
|
const urls = line.split(' ');
|
||
|
lines[i] = urlReplacer(urls[0]) + ' ' + urlReplacer(urls[1]);
|
||
|
}
|
||
|
else
|
||
|
lines[i] = urlReplacer(line);
|
||
|
}
|
||
|
}
|
||
|
return lines.join('\n');
|
||
|
}
|
||
|
shouldProcessResource(ctx) {
|
||
|
return ctx.contentInfo.isManifest;
|
||
|
}
|
||
|
}
|
||
|
exports.default = new ManifestProcessor();module.exports = exports.default;
|
||
|
|