Closed abotteram closed 5 years ago
Build an API that builds a URL using a urlStructure and urlParts.
urlStructure and urlParts
const urlStructure = "https://www.example.com/%category%/%postname%/"; const urlParts = { category: [ "transportation", "flying" ], postname: "the-cost-of-flying", }; // Outputs: https://www.example.com/transportation/flying/the-cost-of-flying buildStructuredUrl( urlStructure, urlParts );
Specs:
urlStructure
urlParts
/
%
Build an API that builds a URL using a
urlStructure and urlParts
.Specs:
urlStructure
must be a string.urlParts
is a key/value pair object.urlParts
values can be either a string or an array. In case of an array, the API will join the parts together using/
.urlParts
correspond to their counterparts in theurlStructure
surrounded by%
, and are inserted in those locations in theurlStructure
.