File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -77,9 +77,11 @@ describe('handleTrailingSlash', () => {
77
77
expect ( expectation ) . toBe ( 'https://example.com/' ) ;
78
78
} ) ;
79
79
80
- it ( 'should never add trailing slashes to paths with file extensions ' , ( ) => {
81
- const expectation = handleTrailingSlash ( '404.html' , 'always' ) ;
80
+ it ( 'should never add trailing slashes to error pages ' , ( ) => {
81
+ let expectation = handleTrailingSlash ( '404.html' , 'always' ) ;
82
82
expect ( expectation ) . toBe ( '404.html' ) ;
83
+ expectation = handleTrailingSlash ( 'https://example.com/403.html/403.html' , 'always' ) ;
84
+ expect ( expectation ) . toBe ( 'https://example.com/403.html/403.html' ) ;
83
85
} ) ;
84
86
} ) ;
85
87
Original file line number Diff line number Diff line change 1
1
import { posix as nodePath } from 'path' ;
2
2
import { PluginOptions } from 'gatsby' ;
3
3
4
+ const ERROR_PAGE_PATH_PATTERN = / [ 0 - 9 ] { 3 } \. ( [ 0 - 9 a - z ] + ) (?: [ ? # ] | $ ) / gim;
5
+
4
6
export const handleTrailingSlash = ( path : string , trailingSlashOption : PluginOptions [ 'trailingSlash' ] = 'always' ) => {
5
- if ( path === '/' || path . length < 1 ) {
7
+ if ( path === '/' || path . length < 1 || path . match ( ERROR_PAGE_PATH_PATTERN ) ) {
6
8
return path ;
7
9
}
8
10
You can’t perform that action at this time.
0 commit comments