File tree Expand file tree Collapse file tree
tests/routing/middleware/redirects Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ export const hasLiquid = /[{{][{%]/
2828export const dataReference = / { % ? d a t a \s (?: e a r l y - a c c e s s \. ) ? (?: r e u s a b l e s | v a r i a b l e s | u i ) \. .* ?% } / gm
2929export const imagePath = / \/ ? a s s e t s \/ i m a g e s \/ .* ?\. ( p n g | s v g | g i f | p d f | i c o | j p g | j p e g ) / gi
3030export const homepagePath = / ^ \/ \w { 2 } $ / // /en, /ja /cn
31- export const multipleSlashes = / ^ \/ { 2 , } /
31+ export const multipleSlashes = / ^ ( \/ | \\ ) { 2 , } /
3232export const assetPaths = / \/ (?: j a v a s c r i p t s | s t y l e s h e e t s | a s s e t s | n o d e _ m o d u l e s | d i s t | _ n e x t ) \/ /
3333export const oldApiPath = / \/ v [ 3 4 ] \/ (? ! g u i d e s | o v e r v i e w ) .+ ?\/ .+ /
3434export const staticRedirect = / < l i n k r e l = " c a n o n i c a l " h r e f = " ( .+ ?) " > /
Original file line number Diff line number Diff line change @@ -83,4 +83,19 @@ describe('help.github.com redirect middleware', () => {
8383 `<p>Moved Permanently. Redirecting to <a href="${ expectedRedirect } ">${ expectedRedirect } </a></p>`
8484 )
8585 } )
86+
87+ it ( 'only redirects to a docs.github.com path backlash edition' , async ( ) => {
88+ const req = {
89+ hostname : 'help.github.com' ,
90+ protocol : 'https' ,
91+ originalUrl : '/\\evil.com' ,
92+ }
93+ const res = new MockExpressResponse ( )
94+ const next = jest . fn ( )
95+ await middleware ( req , res , next )
96+ const expectedRedirect = 'https://docs.github.com/evil.com'
97+ expect ( res . _getString ( ) ) . toEqual (
98+ `<p>Moved Permanently. Redirecting to <a href="${ expectedRedirect } ">${ expectedRedirect } </a></p>`
99+ )
100+ } )
86101} )
You can’t perform that action at this time.
0 commit comments