:relfileprefix: ../../../
[#boost-urls-url_view_base-zone_id]

= xref:boost.adoc[pass:[boost]]::xref:boost/urls.adoc[pass:[urls]]::xref:boost/urls/url_view_base.adoc[pass:[url_view_base]]::zone_id


Return the IPv6 Zone ID


== Synopsis

Declared in header `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/url_view_base.hpp#L1406[boost/url/url_view_base.hpp,window=blank_]>`

[source,cpp,subs="verbatim,macros,-callouts"]
----
template<class StringToken = xref:boost/urls/string_token.adoc[string_token]::xref:boost/urls/string_token/return_string.adoc[return_string]>
StringToken::result_type
zone_id(StringToken&& token) const;
----

== Description


If the host type is
xref:boost/urls/host_type/ipv6.adoc[host_type::ipv6]
,        this function returns the Zone ID as
a string. Otherwise an empty string is returned.
Any percent-escapes in the string are
decoded first.

=== Example
[,cpp]
----
assert( url_view( "http://[fe80::1%25eth0]/" ).zone_id() == "eth0" );
----

=== Complexity

Linear in `this-&gt;encoded_zone_id().size()`.

=== Exception Safety

Calls to allocate may throw.

=== BNF
[,cpp]
----
host        = IP-literal / IPv4address / reg-name

IP-literal = "[" ( IPv6address / IPv6addrz / IPvFuture  ) "]"

ZoneID = 1*( unreserved / pct-encoded )

IPv6addrz = IPv6address "%25" ZoneID
----

=== Specification

* link:https://datatracker.ietf.org/doc/html/rfc6874[Representing IPv6 Zone Identifiers in Address Literals and Uniform Resource Identifiers]








