Generic Function | Package: net.uri | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 10.1 Unrevised from 10.0 to 10.1. 10.0 version

## merge-uris

Arguments: uri base-uri &optional place

Return an absolute URI, based on uri, which can be relative, and base-uri which must be absolute. place can be used as storage for the result.

Note: bad things will happen if you use an interned URI as the result for merging. The result is not interned.

The rules for merging URIs are not the same as for merging pathnames. A simplified version of the merge rules from RFC2396 are (applied in order):

- If uri has no scheme, authority or path, then the query and fragment from uri are used, and all other slots are inherited from the base-uri.
- If uri has a scheme, then uri is returned. If it does not have a scheme, then it inherits one from the base-uri.
- If uri has a host, the unmodified uri is returned.
- If the path of uri is absolute (starts with a /), then the unmodified uri is returned.
- Otherwise, the path of base-uri and uri are concatenated into a uri path, and the new uri is returned.

One comment about error checking of URIs as a result of merging: RFC2396 says that an implementation may handle too many ..'s in a merge result "by retaining these components in the resolved path, by removing them from the resolved path, or by avoiding traversal of the reference." The examples in appendix C of RFC2396 imply that an implementation should retain these invalid elements, so that is what we do. For example,

    (merge-uris (parse-uri "../../../../g")
                (parse-uri "http://a/b/c/d;p?q"))

should return `#<uri "http://a/../../g">`, which is clearly a nonsense result, but this is what our implementation returns, instead of signaling an error.

See also uri.htm for general information on Universal Resource Indicator support in Allegro CL.

Copyright (c) 1998-2022, Franz Inc. Lafayette, CA., USA. All rights reserved.
This page was not revised from the 10.0 page.
Created 2019.8.20.

|  | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 10.1 Unrevised from 10.0 to 10.1. 10.0 version