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

Method normalize

packages/common/upgrade/src/params.ts:175–210  ·  view source on GitHub ↗
(
    pathOrHref: string,
    search?: {[k: string]: unknown},
    hash?: string,
    baseUrl?: string,
  )

Source from the content-addressed store, hash-verified

173 normalize(href: string): string;
174 normalize(path: string, search: {[k: string]: unknown}, hash: string, baseUrl?: string): string;
175 normalize(
176 pathOrHref: string,
177 search?: {[k: string]: unknown},
178 hash?: string,
179 baseUrl?: string,
180 ): string {
181 if (arguments.length === 1) {
182 const parsed = this.parse(pathOrHref, baseUrl);
183
184 if (typeof parsed === 'string') {
185 return parsed;
186 }
187
188 const serverUrl = `${parsed.protocol}://${parsed.hostname}${
189 parsed.port ? ':' + parsed.port : ''
190 }`;
191
192 return this.normalize(
193 this.decodePath(parsed.pathname),
194 this.decodeSearch(parsed.search),
195 this.decodeHash(parsed.hash),
196 serverUrl,
197 );
198 } else {
199 const encPath = this.encodePath(pathOrHref);
200 const encSearch = (search && this.encodeSearch(search)) || '';
201 const encHash = (hash && this.encodeHash(hash)) || '';
202
203 let joinedPath = (baseUrl || '') + encPath;
204
205 if (!joinedPath.length || joinedPath[0] !== '/') {
206 joinedPath = '/' + joinedPath;
207 }
208 return joinedPath + encSearch + encHash;
209 }
210 }
211
212 areEqual(valA: string, valB: string) {
213 return this.normalize(valA) === this.normalize(valB);

Callers 1

areEqualMethod · 0.95

Calls 7

parseMethod · 0.95
decodePathMethod · 0.95
decodeSearchMethod · 0.95
decodeHashMethod · 0.95
encodePathMethod · 0.95
encodeSearchMethod · 0.95
encodeHashMethod · 0.95

Tested by

no test coverage detected