You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
398 B
JavaScript

"use strict";
// FIXME: Publish this some day, and switch to it instead of the `make-url` package (which has a magic API)
module.exports = function makeURL(template, options) {
return template.replace(/:([^\/]+)/gi, (_, property) => {
if (options[property] != null) {
return encodeURIComponent(options[property]);
} else {
throw new Error(`Missing property: ${property}`);
}
});
};