Entfernen subdomain von string in ruby

Wechsele ich über eine Reihe von URLs und will Sie zu bereinigen. Ich habe den folgenden code:

# Parse url to remove http, path and check format
o_url = URI.parse(node.attributes['href'])

# Remove www
new_url = o_url.host.gsub('www.', '').strip

Wie kann ich das verlängern, um die subdomains, die es in manchen URLs?

InformationsquelleAutor | 2009-06-11
Schreibe einen Kommentar