/// <summary> /// Resolve a given URI against the base URI. /// </summary> /// <param name="uriString">the given URI</param> /// <returns>the resolved URI</returns> public virtual Uri ResolveAgainstBaseUri(String uriString) { Uri resolvedUrl = null; uriString = uriString.Trim(); // decode and then encode uri string in order to process unsafe characters correctly uriString = UriEncodeUtil.Encode(uriString); if (isLocalBaseUri) { if (!uriString.StartsWith("file:")) { try { String path = System.IO.Path.Combine(uriString); // In general this check is for windows only, in order to handle paths like "c:/temp/img.jpg". // What concerns unix paths, we already removed leading slashes, // therefore we can't meet here an absolute path. if (Path.IsPathRooted(path)) { resolvedUrl = new Uri(path); } } catch (Exception) { } } } if (resolvedUrl == null) { resolvedUrl = new Uri(baseUrl, uriString); } return(resolvedUrl); }
/// <summary> /// Resolves the base URI to an URL or path. /// </summary> /// <param name="base">the base URI</param> private void ResolveBaseUrlOrPath(String @base) { @base = @base.Trim(); @base = UriEncodeUtil.Encode(@base); baseUrl = BaseUriAsUrl(@base); if (baseUrl == null) { baseUrl = UriAsFileUrl(@base); } if (baseUrl == null) { throw new ArgumentException(MessageFormatUtil.Format("Invalid base URI: {0}", @base)); } }
/// <summary> /// Resolves the base URI to an URL or path. /// </summary> /// <param name="base">the base URI</param> private void ResolveBaseUrlOrPath(String @base) { //TODO: RND-1019 // this method produces // a behavior that is not consistant in java vs .Net //when resolving some characters ex. scaped backwards lash @base = @base.Trim(); @base = UriEncodeUtil.Encode(@base); baseUrl = BaseUriAsUrl(@base); if (baseUrl == null) { baseUrl = UriAsFileUrl(@base); } if (baseUrl == null) { // TODO Html2PdfException? throw new ArgumentException(MessageFormatUtil.Format("Invalid base URI: {0}", @base)); } }