i'd use uri or cgi libraries path query part of url. in other words, just: '/scouting/amateur'. possible or need use regexp?
http://10.241.180.63:3149/login?redirect_path=http%3a%2f%2f10.241.180.63%3a3149%2fscouting%2famateur
suggestion ruby built-ins (if designing method, might want implement error handling).
require 'uri' query = uri("http://10.241.180.63:3149/login?redirect_path=http%3a%2f%2f10.241.180.63%3a3149%2fscouting%2famateur").query path = uri(uri.decode(query).split('=')[1]).path you may find gem uri-query_params helpful / more elegant (it decode query params automatically). e.g.
require 'uri/query_params' uri = uri("http://10.241.180.63:3149/login?redirect_path=http%3a%2f%2f10.241.180.63%3a3149%2fscouting%2famateur") uri(uri.query_params["redirect_path"]).path
Comments
Post a Comment