Skip to main content

Module encode

Module encode 

Source
Expand description

Encoding and decoding between S3Location and its various string forms.

Three distinct output forms:

  • Canonical URI (brows3r://<profile_id>/<bucket>/<key>) — used for Copy Path, navigation state, and any IPC surface that must be unambiguous even when two profiles share a display name.
  • Display pathDisplayPath for the breadcrumb UI. Human-readable, not URL-encoded.
  • Clipboard string (s3://<bucket>/<key>) — the aws-cli-compatible form users paste into a terminal.

§Percent-encoding rules

The canonical URI encodes bucket names and the full key/prefix string using percent-encoding’s NON_ALPHANUMERIC set (encodes everything except [A-Za-z0-9]), then un-encodes / back to a literal / in the key segment only. This preserves the S3 hierarchy-separator semantics while ensuring that ?, #, %, and other special characters are always escaped.

Bucket names are encoded without slash restoration (S3 bucket names cannot contain /).

Functions§

decode_component 🔒
Percent-decode a URI component, returning a UTF-8 string.
encode_no_slash 🔒
Percent-encode a string, encoding ALL non-alphanumeric characters (including /). Used for bucket names.
encode_preserve_slash 🔒
Percent-encode a string, encoding all non-alphanumeric characters EXCEPT /. Used for key/prefix segments.
from_canonical_uri
Parse a brows3r:// URI back into an S3Location.
from_display_path
Reconstruct an S3Location from breadcrumb segments.
to_canonical_uri
Encode an S3Location into its canonical brows3r:// URI.
to_clipboard_string
Produce the aws-cli-compatible s3:// string for clipboard use.
to_display_path
Build a DisplayPath from an S3Location.