Composing a Pack URI

The following is an algorithm for composing a pack URI from the URI of an entire package resource and a part name.

In order to be suitable for creating a pack URI, the URI reference of a package resource shall conform to RFC 3986 requirements for valid absolute URIs.

To compose a pack URI from the absolute package URI and a part name, the following steps shall be performed, in order:

  1. Remove the fragment identifier from the package URI, if present.

  2. Percent-encode all percent signs (%), question marks (?), at signs (@), colons (:) and commas (,) in the package URI.

  3. Replace all forward slashes (/) with commas (,) in the resulting string.

  4. Append the resulting string to the string “pack://”.

  5. Append a forward slash (/) to the resulting string. The constructed string represents a pack URI with a blank path component.

  6. Using this constructed string as a base URI and the part name as a relative reference, apply the rules defined in RFC 3986 for resolving relative references against the base URI.

The result of this operation will be the pack URI that refers to the resource specified by the part name.

example:

Example B–5. Composing a pack URI

Given the package URI:

http://www.my.com/packages.aspx?my.package

And the part name:

/a/foo.xml

The pack URI is:

pack://http%3c,,www.my.com,packages.aspx%3fmy.package/a/foo.xml