File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
88## [ Unreleased]
99
10+ ## [ 2.0.4] - 2024-07-19
11+
12+ ### Added
13+
14+ - Add task 'parse URL' for breaking for hard to read URL's
15+
1016## [ 2.0.3] - 2023-06-05
1117
1218### Added
Original file line number Diff line number Diff line change @@ -204,6 +204,7 @@ <h1>Online tools</h1>
204204< aside >
205205 < form id ="tasks ">
206206 < fieldset >
207+ < label > < input type ="radio " name ="task " value ="url2json " required > parse URL</ label >
207208 < label > < input type ="radio " name ="task " value ="urlEncode " required > URL encode</ label >
208209 < label > < input type ="radio " name ="task " value ="urlDecode " required > URL decode</ label >
209210 < label > < input type ="radio " name ="task " value ="base64Encode " required > base64 encode</ label >
@@ -263,7 +264,26 @@ <h1>Online tools</h1>
263264 return Object . fromEntries ( data ) ;
264265} ;
265266
267+ function parseUrl ( url ) {
268+ const u = new URL ( url ) ;
269+ const params = [ ] ;
270+ for ( const [ key , value ] of u . searchParams ) {
271+ params . push ( { [ key ] : value } ) ;
272+ }
273+ return {
274+ scheme : u . protocol ,
275+ username : u . username ,
276+ password : u . password ,
277+ host : u . hostname ,
278+ port : u . port ,
279+ path : u . pathname ,
280+ query : params ,
281+ fragment : u . hash ,
282+ } ;
283+ }
284+
266285const tasks = {
286+ url2json : ( data ) => JSON . stringify ( parseUrl ( data ) , null , 2 ) ,
267287 urlEncode : ( data ) => encodeURIComponent ( data ) ,
268288 urlDecode : ( data ) => decodeURIComponent ( data ) ,
269289 base64Encode : ( data ) => window . btoa ( data ) ,
You can’t perform that action at this time.
0 commit comments