mrp-url-generator

1.0.6 • Public • Published

MR PORTER URL Generator Build status

An isomorphic JavaScript library to generate URLs used across the MR PORTER sites, following our agreed formatting conventions.

Usage

npm i mrp-url-generator --save

ECMAScript 6

import { buildProductDetailsUrl } from 'mrp-url-generator';

/* alternatively, one can import the entire library with:
 * import urlGen from 'mrp-url-generator'; */

ECMAScript 5

var buildProductDetailsUrl = require('mrp-url-generator').buildProductDetailsUrl;

Browser

This is confirmed to work with Browserify and Webpack.

If, unfortunately, script tag includes are the only option, one must build the distributable manually with a tool such as Browserify:

browserify dist/index.js --outfile mrp-url-generator.js

API

All methods return Strings representing relative URLs

buildProductDetailsUrl(brandUrlKey, productName, productId, locale)

Returns a product details page link e.g:

//returns '/en-gb/mens/mario_super_designer/my-3456-woouuuuderful-trou-ers-are-great/12345'
buildProductDetailsUrl('Mario_Super_Designer', 'My 3456 Ẅöőuúüűderful Trou$ers! Are great', 12345, 'en-gb');

Contributing

Setup

npm i -g babel
npm i

Babel?! Why does this project use ECMAScript 6?

  1. Harmony has a lot of useful enhancements, especially to String.prototype
  2. Once io.js has fully merged with Node.js, everything should just work!
  3. Native Harmony support is gradually improving

Tasks

  • npm run dist - compiles the distributable to ECMAScript 5
  • npm test - runs unit tests

Dependents (0)

Package Sidebar

Install

npm i mrp-url-generator

Weekly Downloads

2

Version

1.0.6

License

BSD

Last publish

Collaborators

  • mrporteradmin