Skip to content

This module converts json file to list of URLs (Test task for StarOfService)

License

Notifications You must be signed in to change notification settings

togran/json-to-url

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsont-to-url

This module converts json file to list of URLs

Usage:

json-to-url.js ./test.json or yarn convert ./test.json

Task description:

Develop a script which returns a list of URLs based on a given input data. Input data is a JSON file provided as an argument. This file contains Array of Hashes, and every such Hash represents an object with possible fields:

  • scheme: string, valid values: http|https
  • username: an alphanumeric string
  • password: an alphanumeric string
  • domain_name: valid domain name
  • port: integer
  • path: string
  • query: Hash with key-value pairs
  • fragment: string
  • disabled: boolean

domain_name is a single required field, the rest are optional

The output is printed to STDOUT, every URL on a separate line. All errors and exceptions have to be sent to STDERR.

Example

Input:

   {
       "scheme": "http",
       "domain_name": "www.anydomain.com",
       "path": "path/to/file",
       "fragment": "header2"
   },
   {
       "scheme": "http",
       "domain_name": "www.domain2.com",
       "disabled": true
   },
   {
       "scheme": "https",
       "domain_name": "www.somedomain.com",
       "path": "some/path",
       "query": {
           "key1": "value1",
           "key2": "value2"
       }
   }
]

Output:

https://www.somedomain.com/some/path?key1=value1&key2=value2

About

This module converts json file to list of URLs (Test task for StarOfService)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published