1.2.0 • Published 5 years ago

leboncoin-reverse-url v1.2.0

Weekly downloads
24
License
-
Repository
-
Last release
5 years ago

leboncoin-reverse-url

converts any leboncoin url (string with ?query) to its equivalent params (object) for api calls

Install

npm install leboncoin-reverse-url

Usage

const reverseUrl = require('leboncoin-reverse-url');

const url = 'https://www.leboncoin.fr/recherche/?category=10&text=studio&locations=Rennes&owner_type=pro&furnished=2&real_estate_type=2&price=150-350'
const params = reverseUrl(url)

Returns an object:

{  
   "filters":{  
      "category":{  
         "id":"10"
      },
      "enums":{  
         "ad_type":[  
            "offer"
         ],
         "furnished":[  
            "2"
         ],
         "real_estate_type":[  
            "2"
         ]
      },
      "ranges":{  
         "price":{  
            "min":150,
            "max":350
         }
      },
      "keywords":{  
         "text":"studio"
      }
   },
   "owner_type":"pro",
   "limit":35,
   "limit_alu":3,
   "offset":0
}

Test

npm run test

Serve

npm run start

Codesandbox playground

Play with it on https://codesandbox.io/s/github/maximelebreton/leboncoin-reverse-url

1.2.0

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago