【问题标题】:Get back full URI from Addressable object?从 Addressable 对象取回完整的 URI?
【发布时间】:2026-01-13 15:15:01
【问题描述】:

如果我有这样的可寻址对象:

uri = Addressable::URI.parse("http://example.com/path/to/resource/")

我将如何取回“http://example.com/path/to/resource/” - 我查看了 uri.methods,但我没有看到我将使用哪个来取回完整的 URI。

【问题讨论】:

    标签: ruby addressable-gem


    【解决方案1】:

    使用to_s方法:

    uri = Addressable::URI.parse("http://example.com/path/to/resource/")
    uri.to_s
    # => "http://example.com/path/to/resource/"
    

    URI - basic example

    【讨论】:

    • 天哪。容易,但我想不通。谢谢。