@@ -158,6 +158,54 @@ describe('skip-trailing-slash-redirect', () => {
158158 expect ( await res . text ( ) ) . toContain ( 'another page' )
159159 } )
160160
161+ it ( 'should not apply trailing slash to links on client' , async ( ) => {
162+ const browser = await webdriver ( next . url , '/' )
163+ await browser . eval ( 'window.beforeNav = 1' )
164+
165+ expect (
166+ new URL (
167+ await browser . elementByCss ( '#to-another' ) . getAttribute ( 'href' ) ,
168+ 'http://n'
169+ ) . pathname
170+ ) . toBe ( '/another' )
171+
172+ await browser . elementByCss ( '#to-another' ) . click ( )
173+ await browser . waitForElementByCss ( '#another' )
174+
175+ expect ( await browser . eval ( 'window.location.pathname' ) ) . toBe ( '/another' )
176+
177+ await browser . back ( ) . waitForElementByCss ( '#to-another' )
178+
179+ expect (
180+ new URL (
181+ await browser
182+ . elementByCss ( '#to-another-with-slash' )
183+ . getAttribute ( 'href' ) ,
184+ 'http://n'
185+ ) . pathname
186+ ) . toBe ( '/another/' )
187+
188+ await browser . elementByCss ( '#to-another-with-slash' ) . click ( )
189+ await browser . waitForElementByCss ( '#another' )
190+
191+ expect ( await browser . eval ( 'window.location.pathname' ) ) . toBe ( '/another/' )
192+
193+ await browser . back ( ) . waitForElementByCss ( '#to-another' )
194+ expect ( await browser . eval ( 'window.beforeNav' ) ) . toBe ( 1 )
195+ } )
196+
197+ it ( 'should not apply trailing slash on load on client' , async ( ) => {
198+ let browser = await webdriver ( next . url , '/another' )
199+ await check ( ( ) => browser . eval ( 'next.router.isReady ? "yes": "no"' ) , 'yes' )
200+
201+ expect ( await browser . eval ( 'location.pathname' ) ) . toBe ( '/another' )
202+
203+ browser = await webdriver ( next . url , '/another/' )
204+ await check ( ( ) => browser . eval ( 'next.router.isReady ? "yes": "no"' ) , 'yes' )
205+
206+ expect ( await browser . eval ( 'location.pathname' ) ) . toBe ( '/another/' )
207+ } )
208+
161209 it ( 'should not apply trailing slash redirect (with slash)' , async ( ) => {
162210 const res = await fetchViaHTTP ( next . url , '/another/' , undefined , {
163211 redirect : 'manual' ,
0 commit comments