MCPcopy Create free account
hub / github.com/porsager/postgres / parseUrl

Function parseUrl

cjs/src/index.js:537–559  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

535}
536
537function parseUrl(url) {
538 if (!url || typeof url !== 'string')
539 return { url: { searchParams: new Map() } }
540
541 let host = url
542 host = host.slice(host.indexOf('://') + 3).split(/[?/]/)[0]
543 host = decodeURIComponent(host.slice(host.indexOf('@') + 1))
544
545 const urlObj = new URL(url.replace(host, host.split(',')[0]))
546
547 return {
548 url: {
549 username: decodeURIComponent(urlObj.username),
550 password: decodeURIComponent(urlObj.password),
551 host: urlObj.host,
552 hostname: urlObj.hostname,
553 port: urlObj.port,
554 pathname: urlObj.pathname,
555 searchParams: urlObj.searchParams
556 },
557 multihost: host.indexOf(',') > -1 && host
558 }
559}
560
561function osUsername() {
562 try {

Callers 1

parseOptionsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected