hyTags
HomeHome DocumentationDocumentation

url-set

Sets components of a URL and returns a new URL
Parameter
Type
Description
self
Url
The URL to modify
schema
String?
The new scheme, or nil to keep unchanged
host
String?
The new host, or nil to keep unchanged
port
Number?
The new port, or nil to keep unchanged
path
String?
The new path, or nil to keep unchanged
query
String?
The new query string, or nil to keep unchanged
anchor
String?
The new anchor, or nil to keep unchanged
return
url
A new URL with the specified components updated
Test Case:Set URL host
    <div></div>
    
    <url-from-string string="https://example.com/path">
    <url-set host="newhost.com">
    <url-to-string>
    <assert-equal value="https://newhost.com/path" type="string">
    
    👆 Try to change something!
  • Test Case:Set URL path
      <div></div>
      
      <url-from-string string="https://example.com/path">
      <url-set path="/new/path">
      <url-to-string>
      <assert-equal value="https://example.com/new/path" type="string">
      
      👆 Try to change something!
    • Test succeeded Test failed