"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.read = exports.fetch = void 0;
const fs_1 = require("../../../../util/fs");
const regex_1 = require("../../../../util/regex");
function convertLinesToVersions(content) {
    const lines = content.split(regex_1.newlineRegex).map((line) => line.trim());
    const versions = lines.map((value) => {
        return { version: value };
    });
    return {
        releases: versions,
    };
}
async function fetch(http, url) {
    const response = await http.getPlain(url);
    const contentType = response.headers['content-type'];
    if (!contentType?.startsWith('text/')) {
        return null;
    }
    return convertLinesToVersions(response.body);
}
exports.fetch = fetch;
async function read(path) {
    const fileContent = await (0, fs_1.readLocalFile)(path, 'utf8');
    return fileContent ? convertLinesToVersions(fileContent) : null;
}
exports.read = read;
//# sourceMappingURL=plain.js.map