module Noir::UrlOrigin

Overview

The origin (scheme + host + port) of a URL, used to decide whether two URLs address the same server. Delivery uses it to keep the user's --probe-header secrets pinned to the --url target.

Defined in:

utils/url_origin.cr

Constant Summary

DEFAULT_PORTS = {"http" => 80, "https" => 443, "ws" => 80, "wss" => 443}

Ports that are implied by the scheme, so https://api.test and https://api.test:443 compare equal.

Class Method Summary

Class Method Detail

def self.of(url : String | Nil) : String | Nil #

scheme://host[:port], downcased, or nil when the URL names no host — a bare path (/users), an empty string, junk that will not parse. A host-less URL has no origin to compare, and callers treat that as "unknown" rather than as a match.

A scheme-less authority (example.com/x, which -u accepts) parses as a path with no host, so it gets one parse attempt with http:// prepended — the same accommodation the OAS builder makes for -u.


[View source]