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

Function parseUrl

cf/src/index.js:538–560  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

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

Callers 1

parseOptionsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected