MCPcopy Index your code
hub / github.com/angular/angular / parse

Method parse

packages/common/upgrade/src/params.ts:217–234  ·  view source on GitHub ↗
(url: string, base?: string)

Source from the content-addressed store, hash-verified

215
216 // https://github.com/angular/angular.js/blob/864c7f0/src/ng/urlUtils.js#L60
217 parse(url: string, base?: string) {
218 try {
219 // Safari 12 throws an error when the URL constructor is called with an undefined base.
220 const parsed = !base ? new URL(url) : new URL(url, base);
221 return {
222 href: parsed.href,
223 protocol: parsed.protocol ? parsed.protocol.replace(/:$/, '') : '',
224 host: parsed.host,
225 search: parsed.search ? parsed.search.replace(/^\?/, '') : '',
226 hash: parsed.hash ? parsed.hash.replace(/^#/, '') : '',
227 hostname: parsed.hostname,
228 port: parsed.port,
229 pathname: parsed.pathname.charAt(0) === '/' ? parsed.pathname : '/' + parsed.pathname,
230 };
231 } catch (e) {
232 throw new Error(`Invalid URL (${url}) with base (${base})`);
233 }
234 }
235}
236
237function _stripIndexHtml(url: string): string {

Callers 1

normalizeMethod · 0.95

Calls 2

charAtMethod · 0.80
replaceMethod · 0.45

Tested by

no test coverage detected