added URI{Component,}{De,En}coder
This commit is contained in:
		
							parent
							
								
									4197bca299
								
							
						
					
					
						commit
						5a1ca42f0d
					
				
					 6 changed files with 70 additions and 83 deletions
				
			
		
							
								
								
									
										15
									
								
								app/converter/uricomponentdecoder.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								app/converter/uricomponentdecoder.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,15 @@ | |||
| import {Converter} from "./converter"; | ||||
| 
 | ||||
| export class URIComponentDecoder implements Converter { | ||||
|     getDisplayname():string { | ||||
|         return "Decode URI component"; | ||||
|     } | ||||
| 
 | ||||
|     getId():string { | ||||
|         return "uricomponentdecode"; | ||||
|     } | ||||
| 
 | ||||
|     convert(input:string):string { | ||||
|         return decodeURIComponent(input); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										17
									
								
								app/converter/uricomponentencoder.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								app/converter/uricomponentencoder.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,17 @@ | |||
| import {Converter} from "./converter"; | ||||
| 
 | ||||
| export class URIComponentEncoder implements Converter { | ||||
|     getDisplayname():string { | ||||
|         return "Encode URI component"; | ||||
|     } | ||||
| 
 | ||||
|     getId():string { | ||||
|         return "uricomponentencode"; | ||||
|     } | ||||
| 
 | ||||
|     convert(input:string):string { | ||||
|         return encodeURIComponent(input).replace(/[!'()*]/g, function (c) { | ||||
|             return '%' + c.charCodeAt(0).toString(16); | ||||
|         }); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										15
									
								
								app/converter/uridecoder.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								app/converter/uridecoder.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,15 @@ | |||
| import {Converter} from "./converter"; | ||||
| 
 | ||||
| export class URIDecoder implements Converter { | ||||
|     getDisplayname():string { | ||||
|         return "Decode URI"; | ||||
|     } | ||||
| 
 | ||||
|     getId():string { | ||||
|         return "uridecode"; | ||||
|     } | ||||
| 
 | ||||
|     convert(input:string):string { | ||||
|         return decodeURI(input); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										15
									
								
								app/converter/uriencoder.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								app/converter/uriencoder.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,15 @@ | |||
| import {Converter} from "./converter"; | ||||
| 
 | ||||
| export class URIEncoder implements Converter { | ||||
|     getDisplayname():string { | ||||
|         return "Encode URI"; | ||||
|     } | ||||
| 
 | ||||
|     getId():string { | ||||
|         return "uriencode"; | ||||
|     } | ||||
| 
 | ||||
|     convert(input:string):string { | ||||
|         return encodeURI(input).replace(/%5B/g, '[').replace(/%5D/g, ']'); | ||||
|     } | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue