jj-npm-linkbuilder
v2.0.2
Published
NPM module to programmatically craft URLs
Downloads
5
Readme
jj-npm-linkbuilder
Crafting for localized DMW URLs
Installation
For Node / Browserify
$ npm install jj-npm-linkbuilder
Methods
getLink (brandId, type, id, [countryCode = 'default', utms = ''])
Returns the crafted URL as a String. If no country is specified, the generic URL will be returned.
brandId (String)
ID of the brand to make the URL for (eg jj, on)type (String)
Type of URL to build (product / category / content asset)id (String)
ID of the page / productcountryCode (String)
Country code of the market to retrieve the link for. IfDMW
, a DMW link will be craftedutms (String)
UTMs string to append to the URL
getLinks (brandId, type, id, [utms = ''])
Returns an object containing URL Strings for all markets, plus a generic one.
brandId (String)
ID of the brand to make the URL for (eg jj, on)type (String)
Type of URL to build (product / category / content asset)id (String)
ID of the page / productutms (String)
UTMs string to append to the URL
Example
var linkbuilder = require('jj-npm-linkbuilder');
linkbuilder.getLink('jj', 'product', '12100985_white')
// http://jackjones.com/12100985.html?dwvar_colorPattern=12100985_white
linkbuilder.getLink('jj', 'product', '12100985_white', 'DE')
// http://jackjones.com/de/de/12100985.html?dwvar_colorPattern=12100985_white
linkbuilder.getLink('jj', 'product', '12100985_white', 'DE', 'a=b&c=d')
// http://jackjones.com/de/de/12100985.html?dwvar_colorPattern=12100985_white&a=b&c=d
linkbuilder.getLinks('jj', 'product', '12100985_white')
{
ch: 'http://jack...',
de: 'http://jack...',
dk: 'http://jack...',
...
default: 'http://jack...'
}
License
MIT
Repo changelog
2.0.0
Bingified domains and URL structure
1.0.0
Valid Sputnik links