Explorer

http.url-target

description
The scheme, authority and path with query of a URL. A URL without http:// or https:// is a path of the same origin
type
Fn(url: String) -> Record{
  scheme: Union{#none, #some(@http.scheme)},
  authority: Union{#none, #some(String)},
  path_with_query: Union{#none, #some(String)}
}
expression
fn(url$0) =>
  match @std.string-starts-with(value: $0, prefix: "https://") {
    true =>
      @http.url-target-after(
        scheme: #https<@http.scheme>,
        rest: @core.string-slice(value: $0, start: 8, end: @core.string-length(value: $0))
      ),
    false =>
      match @std.string-starts-with(value: $0, prefix: "http://") {
        true =>
          @http.url-target-after(
            scheme: #http<@http.scheme>,
            rest: @core.string-slice(value: $0, start: 7, end: @core.string-length(value: $0))
          ),
        false =>
          {scheme: #none, authority: #none, path_with_query: #some($0)}
      }
  }
visibility
public
http.url-target (project http, branch main, snapshot FuOge41aUHwwPZkx2JW6O-Emair6Jc-D5YsZf5cx6b0)
id: 5AiHiae5TZOWg-hgBM5CJWXEX0X45ILAk8FjQmDHTPI
content hash: etbrr3IWhLVVhe5MPp5k6m5nOJsqN6VaFVYd8UoVfpM