[#boost-urls-url_base-resolve]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/url_base.adoc[url&lowbar;base]::resolve
:relfileprefix: ../../../
:mrdocs:

Resolve a URL reference against this base URL

== Synopsis

Declared in `&lt;https://www.github.com/boostorg/url/blob/develop/include/boost/url/url_base.hpp#L2888[boost&sol;url&sol;url&lowbar;base&period;hpp]&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
system::result&lt;void&gt;
resolve(xref:boost/urls/url_view_base.adoc[url&lowbar;view&lowbar;base] const& ref);
----

== Description

This function attempts to resolve a URL reference `ref` against this base URL in a manner similar to that of a web browser resolving an anchor tag&period;

This URL must satisfy the _URI_ grammar&period; In other words, it must contain a scheme&period;

Relative references are only usable when in the context of a base absolute URI&period; This process of resolving a relative _reference_ within the context of a _base_ URI is defined in detail in rfc3986 (see below)&period;

The resolution process works as if the relative reference is appended to the base URI and the result is normalized&period;

Given the input base URL, this function resolves the relative reference as if performing the following steps&colon;

* Ensure the base URI has at least a scheme
* Normalizing the reference path
* Merge base and reference paths
* Normalize the merged path

This function places the result of the resolution into this URL in place&period;

If an error occurs, the contents of this URL are unspecified and a `boost&colon;&colon;system&colon;&colon;result` with an `system&colon;&colon;error&lowbar;code` is returned&period;

[NOTE]
Abnormal hrefs where the number of &quot;&period;&period;&quot; segments exceeds the number of segments in the base path are handled by including the unmatched &quot;&period;&period;&quot; segments in the result, as described in https://www.rfc-editor.org/errata/eid4547[]&period;

== Example
[,cpp]
----
url base1( "/one/two/three" );
base1.resolve("four");
assert( base1.buffer() == "/one/two/four" );

url base2( "http://example.com/" )
base2.resolve("/one");
assert( base2.buffer() == "http://example.com/one" );

url base3( "http://example.com/one" );
base3.resolve("/two");
assert( base3.buffer() == "http://example.com/two" );

url base4( "http://a/b/c/d;p?q" );
base4.resolve("g#s");
assert( base4.buffer() == "http://a/b/c/g#s" );
----
== BNF
[,cpp]
----
absolute-URI  = scheme ":" hier-part [ "?" query ]
----
== Exception Safety
Basic guarantee&period; Calls to allocate may throw&period;

== Specification
https://datatracker.ietf.org/doc/html/rfc3986#section-5[]

== Return Value

An empty `boost&colon;&colon;system&colon;&colon;result` upon success, otherwise an error code if `!base&period;has&lowbar;scheme()`&period;

== Parameters

[cols=2]
|===
| Name
| Description
| *ref*
| The URL reference to resolve&period;
|===

== See Also

xref:boost/urls/url.adoc[`url`], xref:boost/urls/url_view.adoc[`url&lowbar;view`]&period;


[.small]#Created with https://www.mrdocs.com[MrDocs]#
