GithubHelp home page GithubHelp logo

cullophid / url-builder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from simonmcmanus/url-builder

0.0 2.0 0.0 212 KB

Build urls based on a url template (as used by express and restify) from an object, when the params are not specified in the tempalte they are added as query params

JavaScript 100.00%

url-builder's Introduction

#URL Builder

Build and prepare URLs for use with Express and Restify routing.

Build Status

This module exposes two functions:

##prepUrl(url, tokens, prepUrl)

Given a URL in the Express/Restify format replace the tokens with the values provided in the tokens object.

The third param (prepUrl) defaults to false but if set to true will pass the URL to the prepUrl function before before it is tokenised.

##tokenise()

Given a URL and tokens object if the key from the tokens object does not already exist in the URL add a new token to the query string, eg:

url: /fruit/:id

params: { id: 123, page: 3 }

Prep url would change the url to:

/fruit/:id?page=:page

and then prepUrl would turn that into:

/fruit/123?page=3

url-builder's People

Contributors

simonmcmanus avatar

Watchers

James Cloos avatar Andreas Møller avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.