Remove subdomain from string in ruby

前端 未结 8 1825
再見小時候
再見小時候 2020-12-17 00:32

I\'m looping over a series of URLs and want to clean them up. I have the following code:

# Parse url to remove http, path and check format
o_url = URI.parse(         


        
8条回答
  •  佛祖请我去吃肉
    2020-12-17 00:58

    Detecting the subdomain of a URL is non-trivial to do in a general sense - it's easy if you just consider the basic ones, but once you get into international territory this becomes tricky.

    Edit: Consider stuff like http://mylocalschool.k12.oh.us et al.

提交回复
热议问题