Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

page-path-builder

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

page-path-builder - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

5

index.js

@@ -16,7 +16,8 @@ var parser = require('./path-parser')

if (!bit.optional && !parameters[bit.name]) {
var defined = typeof parameters[bit.name] !== 'undefined'
if (!bit.optional && !defined) {
throw new Error('Must supply argument ' + bit.name + ' for path ' + pathStr)
}
return parameters[bit.name] ? (bit.delimiter + encodeURIComponent(parameters[bit.name])) : ''
return defined ? (bit.delimiter + encodeURIComponent(parameters[bit.name])) : ''
}).join('')

@@ -23,0 +24,0 @@

{
"name": "page-path-builder",
"version": "1.0.2",
"version": "1.0.3",
"description": "Uses a page.js-style routing string to build up a path you can link to",
"main": "index.js",
"scripts": {
"test": "node test.js"
"test": "node test.js && jsmd readme.md"
},

@@ -20,2 +20,3 @@ "keywords": [

"devDependencies": {
"jsmd": "^0.3.0",
"tape": "^3.0.0"

@@ -22,0 +23,0 @@ },

23

readme.md
[![Build Status](https://travis-ci.org/TehShrike/page-path-builder.svg)](https://travis-ci.org/TehShrike/page-path-builder)
For those times when you want to programmatically generate a link to page.js route.
For those times when you want to programmatically generate a link to a [page.js](https://github.com/visionmedia/page.js) route.

@@ -8,19 +8,16 @@ Usage

var buildPath = require('page-path-builder')
```js
var buildPath = require('./')
var path = buildPath('/wat/:huh/yeah', { huh: 'go figure' })
buildPath('/wat/:huh/yeah', { huh: 'go figure' }) // => '/wat/go%20figure/yeah'
```
console.log(path) // => /wat/go%20figure/yeah
Or parse a path once for more efficient url construction later:
var parsedPath = buildPath('/page/:id')
```js
var parsedPath = buildPath('/page/:id')
var path = buildPath(parsedPath, { id: 13 })
buildPath(parsedPath, { id: 13 }) // => '/page/13'
console.log(path) // => /page/13
var anotherPath = buildPath(parsedPath, { id: 1337 })
console.log(anotherPath) // => /page/1337
buildPath(parsedPath, { id: 1337 }) // => '/page/1337'
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc