compile(params) {
        const segments = this.parameterSegments;

        if (!segments.length) return this.template;

        // This should probably be refactored to build the host and path separately (not the entire URL at once)
        // because that's how Laravel does it internally and it's more precise and less error-prone
        return this.template
            .replace(/{([^}?]+)(\??)}/g, (_, segment, optional) => {
                // If the parameter is missing but is not optional, throw an error
                if (!optional && [null, undefined].includes(params[segment])) {
                    throw new Error(
                        `Ziggy error: '${segment}' parameter is required for route '${this.name}'.`,
                    );
                }

                if (this.wheres[segment]) {
                    if (
                        !new RegExp(
                            `^${optional ? `(${this.wheres[segment]})?` : this.wheres[segment]}$`,
                        ).test(params[segment] ?? '')
                    ) {
                        throw new Error(
                            `Ziggy error: '${segment}' parameter '${params[segment]}' does not match required format '${this.wheres[segment]}' for route '${this.name}'.`,
                        );
                    }
                }

                return encodeURI(params[segment] ?? '')
                    .replace(/%7C/g, '|')
                    .replace(/%25/g, '%')
                    .replace(/\$/g, '%24');
            })
            .replace(this.config.absolute ? /(\.[^/]+?)(\/\/)/ : /(^)(\/\/)/, '$1/')
            .replace(/\/+$/, '');
    }
Hydrate and return a complete URL for this route with the given parameters.

@param {Object} params
@return {String}