| 
									
										
										
										
											2017-05-26 11:02:31 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							|  |  |  |  * Copyright Google Inc. All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Use of this source code is governed by an MIT-style license that can be | 
					
						
							|  |  |  |  * found in the LICENSE file at https://angular.io/license
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-13 11:51:02 +01:00
										 |  |  | import {Location} from '@angular/common'; | 
					
						
							| 
									
										
										
										
											2017-05-26 11:02:31 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-13 11:51:02 +01:00
										 |  |  | const baseUrl = '/base'; | 
					
						
							| 
									
										
										
										
											2017-05-26 11:02:31 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-13 11:51:02 +01:00
										 |  |  | describe('Location Class', () => { | 
					
						
							|  |  |  |   describe('stripTrailingSlash', () => { | 
					
						
							|  |  |  |     it('should strip single character slash', () => { | 
					
						
							|  |  |  |       const input = '/'; | 
					
						
							|  |  |  |       expect(Location.stripTrailingSlash(input)).toBe(''); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2017-05-26 11:02:31 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-13 11:51:02 +01:00
										 |  |  |     it('should normalize strip a trailing slash', () => { | 
					
						
							|  |  |  |       const input = baseUrl + '/'; | 
					
						
							|  |  |  |       expect(Location.stripTrailingSlash(input)).toBe(baseUrl); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2017-05-26 11:02:31 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-13 11:51:02 +01:00
										 |  |  |     it('should ignore query params when stripping a slash', () => { | 
					
						
							|  |  |  |       const input = baseUrl + '/?param=1'; | 
					
						
							|  |  |  |       expect(Location.stripTrailingSlash(input)).toBe(baseUrl + '?param=1'); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2017-05-26 11:02:31 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-13 11:51:02 +01:00
										 |  |  |     it('should not remove slashes inside query params', () => { | 
					
						
							|  |  |  |       const input = baseUrl + '?test/?=3'; | 
					
						
							|  |  |  |       expect(Location.stripTrailingSlash(input)).toBe(input); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2017-05-26 11:02:31 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-13 11:51:02 +01:00
										 |  |  |     it('should not remove slashes after a pound sign', () => { | 
					
						
							|  |  |  |       const input = baseUrl + '#test/?=3'; | 
					
						
							|  |  |  |       expect(Location.stripTrailingSlash(input)).toBe(input); | 
					
						
							| 
									
										
										
										
											2017-05-26 11:02:31 -07:00
										 |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2018-11-13 11:51:02 +01:00
										 |  |  | }); |