@documentica/webdav
Version:
Documentica Webdav Client
25 lines (24 loc) • 1.1 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const reduceServerUrl = (href, config) => {
if (!href.match(/^http[s]*\:\/\//))
return href;
const urlHref = new URL(href).pathname;
const hostHref = config.host.match(/^http[s]*\:\/\//) ? new URL(config.host).pathname : config.host;
return ("/" + (urlHref.substring(hostHref.length))).replace(/\/\//g, "/");
};
exports.multiStatusToPropfindResponse = (body, config) => {
if (!body)
return [];
const result = body.getResponseNames().map(responseName => {
let response = body.getResponse(responseName);
return {
name: reduceServerUrl(response.href, config),
href: reduceServerUrl(response.href, config),
props: response.getPropertyNames("DAV:").reduce((acc, item) => (Object.assign(Object.assign({}, acc), { [item]: response.getProperty("DAV:", item).getParsedValue() })), {})
};
});
if (config.supportedFeatures.ignoreDotFiles)
return result.filter(i => !i.href.match(/^[\/]*\./));
return result;
};
;