const PARAM_IDENTIFIER = /:([^/]+)/g;
/**
 *
 * @param pattern
 * @param params
 */
export function umbUrlPatternToString(pattern, params) {
    return params
        ? pattern.replace(PARAM_IDENTIFIER, (_substring, ...args) => {
            const segmentValue = params[args[0]]; // (segmentValue is the value to replace the parameter)
            // Replace the path-segment with the value from the params object or 'null' if it doesn't exist
            return segmentValue === undefined ? `:${args[0]}` : segmentValue === null ? 'null' : segmentValue.toString();
        })
        : pattern;
}
