Skip to content

urlparse

urlparse(urlstring: string, scheme: string, allowFragments: boolean): ParseResult

Defined in: packages/pythonlib/src/urllib.ts:52

Parse a URL into its components.

Parameters

ParameterTypeDefault valueDescription
urlstringstringundefinedThe URL to parse
schemestring""Default scheme if not present in URL
allowFragmentsbooleantrueWhether to parse fragments (default: true)

Returns

ParseResult

Parsed URL components

Example

const result = urlparse("https://user:pass@example.com:8080/path?query=1#frag")
console.log(result.scheme) // "https"
console.log(result.hostname) // "example.com"
console.log(result.port) // 8080