File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 99//
1010// Helper functions that relate to the HTTP/service layer of the application.
1111
12- const { parse , URL } = require ( 'url' ) ;
12+ const { URL } = require ( 'url' ) ;
1313const { map, tryCatch } = require ( 'ramda' ) ;
1414const { isBlank } = require ( './util' ) ;
1515const Option = require ( './option' ) ;
@@ -24,7 +24,10 @@ const isTrue = (x) => (!isBlank(x) && typeof x === 'string' && (x.toLowerCase()
2424const isFalse = ( x ) => ( ! isBlank ( x ) && typeof x === 'string' && ( x . toLowerCase ( ) === 'false' ) ) ;
2525
2626// Returns just the pathname of the URL, omitting querystring and other non-path decoration.
27- const urlPathname = ( x ) => parse ( x ) . pathname ;
27+ const urlPathname = ( url ) => {
28+ if ( typeof url !== 'string' ) throw new Error ( `The "url" argument must be of type string.` ) ;
29+ return new URL ( url , 'http://example.test' ) . pathname ;
30+ } ;
2831
2932const urlDecode = tryCatch ( map ( Option . of , decodeURIComponent ) , Option . none ) ;
3033
You can’t perform that action at this time.
0 commit comments