On this page
UrlCodec
class
A codec for encoding and decoding URL parts.
abstract class UrlCodec {
  abstract encodePath(path: string): string
  abstract decodePath(path: string): string
  abstract encodeSearch(search: string | { [k: string]: unknown; }): string
  abstract decodeSearch(search: string): {...}
  abstract encodeHash(hash: string): string
  abstract decodeHash(hash: string): string
  abstract normalize(href: string): string
  abstract areEqual(valA: string, valB: string): boolean
  abstract parse(url: string, base?: string): {...}
}
   Subclasses
Methods
| 
         
          encodePath() 
          | 
      |||
|---|---|---|---|
Encodes the path from the provided string  | 
      |||
        
          | 
      
path | 
            string | 
            The path string  | 
           
Returns
string
| 
         
          decodePath() 
          | 
      |||
|---|---|---|---|
Decodes the path from the provided string  | 
      |||
        
          | 
      
path | 
            string | 
            The path string  | 
           
Returns
string
| 
         
          encodeSearch() 
          | 
      |||
|---|---|---|---|
Encodes the search string from the provided string or object  | 
      |||
        
          | 
      
search | 
            string | { [k: string]: unknown; } | 
            
Returns
string
| 
         
          decodeSearch() 
          | 
      |||
|---|---|---|---|
Decodes the search objects from the provided string  | 
      |||
        
          | 
      
search | 
            string | 
            
Returns
`{
}`
| 
         
          encodeHash() 
          | 
      |||
|---|---|---|---|
Encodes the hash from the provided string  | 
      |||
        
          | 
      
hash | 
            string | 
            
Returns
string
| 
         
          decodeHash() 
          | 
      |||
|---|---|---|---|
Decodes the hash from the provided string  | 
      |||
        
          | 
      
hash | 
            string | 
            
Returns
string
| 
         
          normalize() 
          | 
      ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Normalizes the URL from the provided string  | 
      ||||||||||||
        
          | 
      
href | 
            string | 
            
Returns
string
Normalizes the URL from the provided string, search, hash, and base URL parameters
abstract normalize(path: string, search: { [k: string]: unknown; }, hash: string, baseUrl?: string): string
         Parameters
path | 
            string | 
            The URL path  | 
           
search | 
            object | 
            The search object  | 
           
hash | 
            string | 
            The has string  | 
           
baseUrl | 
            string | 
            The base URL for the URL Optional. Default is   | 
           
Returns
string
| 
         
          areEqual() 
          | 
      ||||||
|---|---|---|---|---|---|---|
Checks whether the two strings are equal  | 
      ||||||
        
          | 
      
valA | 
            string | 
            First string for comparison  | 
           
valB | 
            string | 
            Second string for comparison  | 
           
Returns
boolean
| 
         
          parse() 
          | 
      ||||||
|---|---|---|---|---|---|---|
Parses the URL string based on the base URL  | 
      ||||||
        
          | 
      
url | 
            string | 
            The full URL string  | 
           
base | 
            string | 
            The base for the URL Optional. Default is   | 
           
Returns
{ href: string; protocol: string; host: string; search: string; hash: string; hostname: string; port: string; pathname: string; }
© 2010–2021 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
 https://v11.angular.io/api/common/upgrade/UrlCodec