/// <summary> /// Transforms and encodes the given PID URL for the base64-encoded URI part of extended PID URIs. /// Transformation removes the port and sets the correct protocol on the returned value (http or https). /// </summary> /// <param name="pidUrl">The PID URL to transform.</param> /// <returns>The base64-encoded PID URL without the environment prefix "dev-pid" or "qa-pid".</returns> private static string TransformAndBase64EncodePidUrl(string pidUrl, ExtendedUriTemplateResultDTO extendedUriTemplate) { var builder = new UriBuilder(pidUrl) { Port = -1, Host = new Uri(Graph.Metadata.Constants.Resource.PidUrlPrefix).Host }; string httpScheme = extendedUriTemplate.Properties.GetValueOrNull(COLID.Graph.Metadata.Constants.ExtendedUriTemplate.UseHttpScheme, true); if (!string.IsNullOrWhiteSpace(httpScheme) && httpScheme == Graph.Metadata.Constants.Boolean.True) { builder.Scheme = Uri.UriSchemeHttp; } return(Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(builder.Uri.ToString()))); }
/// <summary> /// Transforms and encodes the given PID URL for the encoded URI part of extended PID URIs. /// Transformation removes the port and sets the correct protocol on the returned value (http or https). /// </summary> /// <param name="pidUrl">The PID URL to transform.</param> /// <returns>The encoded PID URL without the environment prefix "dev-pid" or "qa-pid".</returns> private static string TransformAndEncodePidUrl(string pidUrl, ExtendedUriTemplateResultDTO extendedUriTemplate) { var builder = new UriBuilder(pidUrl) { Port = -1, Host = new Uri(Graph.Metadata.Constants.Resource.PidUrlPrefix).Host }; string httpScheme = extendedUriTemplate.Properties.GetValueOrNull(Common.Constants.ExtendedUriTemplate.UseHttpScheme, true); if (!string.IsNullOrWhiteSpace(httpScheme) && httpScheme == Graph.Metadata.Constants.Boolean.True) { builder.Scheme = Uri.UriSchemeHttp; } return(WebUtility.UrlEncode(builder.Uri.ToString())); }