File tree Expand file tree Collapse file tree 2 files changed +6
-20
lines changed
Expand file tree Collapse file tree 2 files changed +6
-20
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
33const { parse, format } = require ( 'url' ) ;
4-
5- const safeDecodeURI = str => {
6- try {
7- return decodeURI ( str ) ;
8- } catch ( err ) {
9- return str ;
10- }
11- } ;
4+ const { unescape } = require ( 'querystring' ) ;
125
136const decodeURL = str => {
147 if ( parse ( str ) . protocol ) {
@@ -18,10 +11,10 @@ const decodeURL = str => {
1811 if ( parsed . origin === 'null' ) return str ;
1912
2013 const url = format ( parsed , { unicode : true } ) ;
21- return safeDecodeURI ( url ) ;
14+ return unescape ( url ) ;
2215 }
2316
24- return safeDecodeURI ( str ) ;
17+ return unescape ( str ) ;
2518} ;
2619
2720module . exports = decodeURL ;
Original file line number Diff line number Diff line change 11'use strict' ;
22
33const { parse, format } = require ( 'url' ) ;
4-
5- const safeDecodeURI = str => {
6- try {
7- return decodeURI ( str ) ;
8- } catch ( err ) {
9- return str ;
10- }
11- } ;
4+ const { unescape } = require ( 'querystring' ) ;
125
136const encodeURL = str => {
147 if ( parse ( str ) . protocol ) {
@@ -17,12 +10,12 @@ const encodeURL = str => {
1710 // Exit if input is a data url
1811 if ( parsed . origin === 'null' ) return str ;
1912
20- parsed . search = encodeURI ( safeDecodeURI ( parsed . search ) ) ;
13+ parsed . search = encodeURI ( unescape ( parsed . search ) ) ;
2114 // preserve IDN
2215 return format ( parsed , { unicode : true } ) ;
2316 }
2417
25- return encodeURI ( safeDecodeURI ( str ) ) ;
18+ return encodeURI ( unescape ( str ) ) ;
2619} ;
2720
2821module . exports = encodeURL ;
You can’t perform that action at this time.
0 commit comments