| 3962 | <section title="Base Fragment Aware Relative Resolution"> |
| 3963 | <t> |
| 3964 | <xref target="RFC3986" x:fmt="of" x:sec="5.2"/> defines the Relative Resolution |
| 3965 | of a URI reference against a Base URI. That algorithm however does not take a |
| 3966 | fragment identifier on the Base URI into account. |
| 3967 | </t> |
| 3968 | <t> |
| 3969 | However in some cases, as when following a redirect from a URI "Base" based |
| 3970 | on a Location header field containing the URI reference "R", it can be |
| 3971 | necessary to preserve a fragment identifier present on "Base". The algorithm described below does this: |
| 3972 | </t> |
| 3973 | <t> |
| 3974 | Given a URI reference "R" and a base URI "Base", to transform R into its |
| 3975 | target URI "T": |
| 3976 | </t> |
| 3977 | <t> |
| 3978 | (1) Pre-parse the Base URI as defined in <xref target="RFC3986" x:fmt="of" x:sec="5.2.1"/>. |
| 3979 | </t> |
| 3980 | <t> |
| 3981 | (2) Transform references as defined in <xref target="RFC3986" x:fmt="of" x:sec="5.2.2"/>. |
| 3982 | If the T.fragment is undefined and Base.fragment is defined, then set |
| 3983 | T.fragment to Base.fragment: |
| 3984 | </t> |
| 3985 | <figure><artwork type="text/plain"> |
| 3986 | if defined(Base.fragment) and not(defined(T.fragment)) then |
| 3987 | T.fragment = Base.fragment; |
| 3988 | endif; |
| 3989 | </artwork></figure> |
| 3990 | <t> |
| 3991 | (3) Merge paths as defined in <xref target="RFC3986" x:fmt="of" x:sec="5.2.3"/>. |
| 3992 | </t> |
| 3993 | <t> |
| 3994 | (4) Remove dot segments as defined in <xref target="RFC3986" x:fmt="of" x:sec="5.2.4"/>. |
| 3995 | </t> |
| 3996 | <t> |
| 3997 | (5) Finally, recompose the components as defined in <xref target="RFC3986" x:fmt="of" x:sec="5.3"/>. |
| 3998 | </t> |
| 3999 | <section title="Examples"> |
| 4000 | <t> |
| 4001 | Starting with a Base URI of "http://host/path1#f1": |
| 4002 | </t> |
| 4003 | <texttable> |
| 4004 | <ttcol>R</ttcol> |
| 4005 | <ttcol>T (after RFC 3986 Relative Resolution)</ttcol> |
| 4006 | <ttcol>T (after Base Fragment Aware Relative Resolution)</ttcol> |
| 4007 | |
| 4008 | <c>/path2</c> |
| 4009 | <c>http://host/path2</c> |
| 4010 | <c>http://host/path2#f1</c> |
| 4011 | |
| 4012 | <c>/path2#f2</c> |
| 4013 | <c>http://host/path2#f2</c> |
| 4014 | <c>http://host/path2#f2</c> |
| 4015 | </texttable> |
| 4016 | |
| 4017 | </section> |
| 4018 | </section> |
| 4019 | |