6. Serializing Origins
6. Serializing Origins
This section defines how to serialize an origin to a Unicode [Unicode6] string and to an ASCII [RFC20] string.
6.1 Unicode Serialization of an Origin
The unicode-serialization of an origin is the value returned by the following algorithm:
-
If the origin is not a scheme/host/port triple, then return the string
null(i.e., the code point sequence U+006E, U+0075, U+006C, U+006C) and abort these steps.
-
Otherwise, let
resultbe the scheme part of the origin triple. -
Append the string "://" to
result. -
Append each component of the host part of the origin triple (converted as follows) to the
result, separated by U+002E FULL STOP code points ("."):-
If the component is an A-label, use the corresponding U-label instead (see [RFC5890] and [RFC5891]).
-
Otherwise, use the component verbatim.
-
-
If the port part of the origin triple is different from the default port for the protocol given by the scheme part of the origin triple:
- Append a U+003A COLON code point (":") and the given port, in base ten, to
result.
- Append a U+003A COLON code point (":") and the given port, in base ten, to
-
Return
result.
6.2 ASCII Serialization of an Origin
The ascii-serialization of an origin is the value returned by the following algorithm:
-
If the origin is not a scheme/host/port triple, then return the string
null(i.e., the code point sequence U+006E, U+0075, U+006C, U+006C) and abort these steps.
-
Otherwise, let
resultbe the scheme part of the origin triple. -
Append the string "://" to
result. -
Append the host part of the origin triple to
result. -
If the port part of the origin triple is different from the default port for the protocol given by the scheme part of the origin triple:
- Append a U+003A COLON code point (":") and the given port, in base ten, to
result.
- Append a U+003A COLON code point (":") and the given port, in base ten, to
-
Return
result.