@@ -22,15 +22,6 @@ import {timeout} from '@angular/private/testing';
2222
2323describe ( 'createUrlTree' , ( ) => {
2424 const serializer = new DefaultUrlSerializer ( ) ;
25- const protocolRelativeUrlWarning = `NG04019: Cannot serialize a UrlTree that would produce a protocol-relative URL. Falling back to '/' instead.` ;
26-
27- function expectProtocolRelativeUrlFallback ( tree : UrlTree ) : void {
28- const warn = spyOn ( console , 'warn' ) ;
29-
30- expect ( serializer . serialize ( tree ) ) . toEqual ( '/' ) ;
31- expect ( warn ) . toHaveBeenCalledOnceWith ( protocolRelativeUrlWarning ) ;
32- }
33-
3425 let router : Router ;
3526 beforeEach ( ( ) => {
3627 router = TestBed . inject ( Router ) ;
@@ -143,62 +134,6 @@ describe('createUrlTree', () => {
143134 expect ( serializer . serialize ( t ) ) . toEqual ( '/%2Fone/two%2Fthree' ) ;
144135 } ) ;
145136
146- describe ( 'leading empty path commands' , ( ) => {
147- it ( 'should fall back for absolute navigations that would serialize as protocol-relative' , ( ) => {
148- const t = router . createUrlTree ( [ '/' , '' , '' , 'attacker.example' , 'collect' ] ) ;
149-
150- expectProtocolRelativeUrlFallback ( t ) ;
151- } ) ;
152-
153- it ( 'should fall back for an unsafe primary outlet string' , async ( ) => {
154- await router . navigateByUrl ( '/safe' ) ;
155- const t = router . createUrlTree ( [ { outlets : { primary : '/attacker.example/collect' } } ] ) ;
156-
157- expectProtocolRelativeUrlFallback ( t ) ;
158- } ) ;
159-
160- it ( 'should fall back for an unsafe primary outlet array' , ( ) => {
161- const t = router . createUrlTree ( [ { outlets : { primary : [ '' , 'attacker.example' , 'collect' ] } } ] ) ;
162-
163- expectProtocolRelativeUrlFallback ( t ) ;
164- } ) ;
165-
166- it ( 'should fall back for unsafe parent-relative commands' , async ( ) => {
167- router . resetConfig ( [ { path : 'source' , component : class { } } ] ) ;
168- await router . navigateByUrl ( '/source' ) ;
169- const t = create ( router . routerState . root . firstChild ! , [
170- '../' ,
171- '' ,
172- 'attacker.example' ,
173- 'collect' ,
174- ] ) ;
175-
176- expectProtocolRelativeUrlFallback ( t ) ;
177- } ) ;
178-
179- it ( 'should fall back for an escaped slash after an empty path command' , ( ) => {
180- const t = router . createUrlTree ( [ '/' , '' , { segmentPath : '/' } ] ) ;
181-
182- expectProtocolRelativeUrlFallback ( t ) ;
183- } ) ;
184-
185- it ( 'should fall back for final empty path commands' , ( ) => {
186- const t = router . createUrlTree ( [ '/' , '' , '' ] ) ;
187-
188- expectProtocolRelativeUrlFallback ( t ) ;
189- } ) ;
190-
191- it ( 'should not normalize a leading empty path command in a secondary outlet' , ( ) => {
192- const t = router . createUrlTree ( [ '/' , { outlets : { right : [ '' , 'child' ] } } ] ) ;
193-
194- expect ( t . root . children [ 'right' ] . segments . map ( ( segment ) => segment . path ) ) . toEqual ( [
195- '' ,
196- 'child' ,
197- ] ) ;
198- expect ( serializer . serialize ( t ) ) . toEqual ( '/(right:/child)' ) ;
199- } ) ;
200- } ) ;
201-
202137 describe ( 'named outlets' , ( ) => {
203138 it ( 'should preserve secondary segments' , async ( ) => {
204139 const p = serializer . parse ( '/a/11/b(right:c)' ) ;
0 commit comments