UNPKG

@aws/cloudfront-hosting-toolkit

Version:

CloudFront Hosting Toolkit offers the convenience of a managed frontend hosting service while retaining full control over the hosting and deployment infrastructure to make it your own.

20 lines (19 loc) 855 B
import { extendedEncodeURIComponent } from "./extended-encode-uri-component"; export const resolvedPath = (resolvedPath, input, memberName, labelValueProvider, uriLabel, isGreedyLabel) => { if (input != null && input[memberName] !== undefined) { const labelValue = labelValueProvider(); if (labelValue.length <= 0) { throw new Error("Empty value provided for input HTTP label: " + memberName + "."); } resolvedPath = resolvedPath.replace(uriLabel, isGreedyLabel ? labelValue .split("/") .map((segment) => extendedEncodeURIComponent(segment)) .join("/") : extendedEncodeURIComponent(labelValue)); } else { throw new Error("No value provided for input HTTP label: " + memberName + "."); } return resolvedPath; };