UNPKG

@achingbrain/ssdp

Version:

Yet another SSDP implementation for node.js

23 lines 638 B
import { parseStringPromise } from 'xml2js'; import { fetch } from '../fetch.js'; export async function resolveLocation(location) { if (location.substring(0, 4) !== 'http') { location = `http://${location}`; } const text = await fetch(location, { method: 'GET', headers: { accept: 'application/xml' } }); const result = await parseStringPromise(text, { normalize: true, explicitArray: false, explicitRoot: true }); if (result == null) { return {}; } return result.root ?? result; } //# sourceMappingURL=resolve-location.js.map