URI utilities. These extend standard FPC URIParser unit.
function CombineUri(const Base, Relative: string): string; |
Return absolute URI, given base and relative URI.
Base URI must be either an absolute (with protocol) URI, or only an absolute filename (in which case we'll convert it to file:// URI under the hood, if necessary). This is usually the URI of the containing file, for example an HTML file referencing the image, processed by AbsoluteURI.
Relative URI may be a relative URI or an absolute URI. In the former case it is merged with Base. In the latter case it is simply returned.
If you want to support relative URIs, you want to use this routine. It treats Relative always as an URI (so it should be percent-escaped, with slashes and such). Other routines in our engine, like AbsoluteUri and Download, treat strings without protocol as a filename (so it's not percent-escaped, it uses PathDelim specific to OS — slash or backslash etc.). This routine, on the other hand, treats Relative string always as an URI (when it doesn't include protocol, it just means it's relative to Base).
|