1.0.5 • Published 2 years ago

@bbfan/populate-url v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@bbfan/populate-url

Helps to populate your URL with path and query parameters. Has a TS support, that parse constant templates and shows expected parameters.

Install

$ npm install @bbfan/populate-url

Usage

const ROUTES = {
  testRoute: '/test/:testId/foo/:bar?id=:id',
} as const;

const populatedUrl = populateUrl(ROUTES.testRoute, {
  id: 123,
  bar: 'test',
  testId: null,
});

console.log(populatedUrl); // /test/null/foo/test?id=123

Examples of valid URL formats

http://test.com/path/:param1/:param2/?id=:id&test=:test

/test.com/path/:param1/:param2/?id=:id&test=:test

test.com/path/:param1/:param2/?id=:id&test=:test

test.com/path/:param1/:param2?id=:id&test=:test

/path/:param1/:param2?id=:id&test=:test

path/:param1/:param2?id=:id&test=:test

path/:param1/:param2

TS Hints Support

plot

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago