From 260e31c0afa0155f9d8398536ffac83208e0755d Mon Sep 17 00:00:00 2001 From: Ross Kaffenberger Date: Tue, 19 Nov 2024 13:41:36 -0500 Subject: [PATCH] addressable: Add Addressable::URI#omit Addressable::URI#omit allows for returning a new instance of Addressable::URI with the specified components omitted. https://github.com/sporkmonger/addressable/blob/4229164843616783287ca359bbe38b574f1908a3/lib/addressable/uri.rb#L2285-L2314 --- gems/addressable/2.8/_test/test.rb | 8 +++++--- gems/addressable/2.8/addressable.rbs | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gems/addressable/2.8/_test/test.rb b/gems/addressable/2.8/_test/test.rb index 15112897..3732452c 100644 --- a/gems/addressable/2.8/_test/test.rb +++ b/gems/addressable/2.8/_test/test.rb @@ -46,9 +46,7 @@ # "fragment" => "foo" # } -uri = Addressable::URI.parse( - "http://example.com/a/b/c" -) +uri = Addressable::URI.parse("http://example.com/a/b/c") uri.query_values # => nil uri.query_values = {"one" => "1", "two" => "2"} uri.query_values # => {"one" => "1", "two" => "2"} @@ -62,3 +60,7 @@ uri.query_values # => {"seven"=>"7", "andup"=>"10"} uri.query_values = nil uri.query_values # => nil + + +uri = Addressable::URI.parse("http://example.com?a=b&c=d") +uri.omit(:query).to_s # => "http://example.com" diff --git a/gems/addressable/2.8/addressable.rbs b/gems/addressable/2.8/addressable.rbs index 8c6aaa9d..0e31ab89 100644 --- a/gems/addressable/2.8/addressable.rbs +++ b/gems/addressable/2.8/addressable.rbs @@ -31,6 +31,7 @@ module Addressable def domain: () -> String def authority: () -> String def authority=: (String new_authority) -> String + def omit: (*Symbol components) -> URI def origin: () -> String def origin=: (String new_origin) -> String attr_reader port: Integer