{"blog_title":"\u30b3\u30fc\u30c9\u65e5\u9032\u6708\u6b69","url":"https://shinkufencer.hateblo.jp/entry/2018/07/10/214202","published":"2018-07-10 21:42:02","provider_url":"https://hatena.blog","image_url":null,"height":"190","title":"Rails\u306erequest.domain\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u5834\u5408\u3001\u30bb\u30ab\u30f3\u30c9\u30ec\u30d9\u30eb\u30c9\u30e1\u30a4\u30f3\u76f8\u5f53\u307e\u3067","version":"1.0","provider_name":"Hatena Blog","author_name":"shinkufencer","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fshinkufencer.hateblo.jp%2Fentry%2F2018%2F07%2F10%2F214202\" title=\"Rails\u306erequest.domain\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u5834\u5408\u3001\u30bb\u30ab\u30f3\u30c9\u30ec\u30d9\u30eb\u30c9\u30e1\u30a4\u30f3\u76f8\u5f53\u307e\u3067 - \u30b3\u30fc\u30c9\u65e5\u9032\u6708\u6b69\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","categories":["Rails","Ruby","Tips"],"description":"domain\u3063\u3066\u66f8\u304b\u308c\u3066\u3044\u308b\u306e\u3067\u30b5\u30d6\u30c9\u30e1\u30a4\u30f3\u3082\u307e\u308b\u3063\u3068\u3072\u3063\u304f\u308b\u3081\u3066\u3082\u3063\u3066\u304f\u308b\u306e\u304b\u3068\u601d\u3044\u304d\u3084\u305d\u3046\u3067\u306f\u306a\u304b\u3063\u305f\u306e\u3067\u30e1\u30e2 \u74b0\u5883 rails (5.2.0) actionpack (= 5.2.0) \u5b9f\u88c5 request.domain\u3092\u6df1\u6398\u308a\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u306b\u7a81\u304d\u5f53\u305f\u308b # /actionpack-5.2.0/lib/action_dispatch/http/url.rb def extract_domain_from(host, tld_length) host.split(\".\").last(1 + tld_length).join(\".\") end \u30db\u30b9\u30c8\u540d\u306b\u5bfe\u3057\u3066\u30c8\u30c3\u30d7\u30ec\u30d9\u30eb\u30c9\u30e1\u30a4\u30f3\u9577\u3055\uff08t\u2026","blog_url":"https://shinkufencer.hateblo.jp/","author_url":"https://blog.hatena.ne.jp/shinkufencer/","width":"100%","type":"rich"}