使用Ruby从url获取Anchor值

时间:2022-11-27 17:51:09

I want to get anchor value from URL using ruby.

我想使用ruby从URL获取锚值。

http://{My-Domain}/signin#recording

HTTP:// {我的域} /登入#记录

Want to get #recording value.

想要获得#recording值。

1 个解决方案

#1


3  

You can use URI.parse to parse the URL, and then look for the attribute fragment:

您可以使用URI.parse来解析URL,然后查找属性片段:

require 'uri'

url = 'http://www.example.com/signin#recording'
uri = URI.parse url
uri.fragment
# => "recording"

#1


3  

You can use URI.parse to parse the URL, and then look for the attribute fragment:

您可以使用URI.parse来解析URL,然后查找属性片段:

require 'uri'

url = 'http://www.example.com/signin#recording'
uri = URI.parse url
uri.fragment
# => "recording"