File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
packages/smooth-backend-wordpress/src/acf/resolvers Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,9 @@ const endBackslashRegExp = /\/+$/
2
2
3
3
export function toRelativeUrl ( baseUrl , url ) {
4
4
const regexp = new RegExp ( `^${ baseUrl . replace ( endBackslashRegExp , '' ) } ` )
5
- return `${ url . replace ( regexp , '' ) } ` || '/'
5
+ const finalUrl = `${ url . replace ( regexp , '' ) } ` || '/'
6
+ if ( finalUrl . startsWith ( ':' ) ) return url
7
+ return finalUrl
6
8
}
7
9
8
10
function formatDateString ( value ) {
Original file line number Diff line number Diff line change @@ -78,5 +78,14 @@ describe('util', () => {
78
78
) ,
79
79
) . toBe ( '/foo?url=http://smooth-code.com' )
80
80
} )
81
+
82
+ it ( 'should avoid replacing url containing port' , ( ) => {
83
+ expect (
84
+ toRelativeUrl (
85
+ 'http://smooth-code.com' ,
86
+ 'http://smooth-code.com:8000/foo' ,
87
+ ) ,
88
+ ) . toBe ( 'http://smooth-code.com:8000/foo' )
89
+ } )
81
90
} )
82
91
} )
You can’t perform that action at this time.
0 commit comments