Home How do I check if URL path strictly?

# How do I check if URL path strictly?

Zena Mesfin
1#
Zena Mesfin Published in 2018-02-13 19:03:22Z
 In my controller method I want to know if the URL path is /404 but not /task/id/95404  redirect_url = request.original_fullpath.include?("404") ? root_path : request.original_url 
Sepzo Sonnus
2#
Sepzo Sonnus Reply to 2018-02-13 19:10:35Z
 How about trying regex expression to find exact url match? May be try this regex : ^/page$Here ^ represents starting and$ is the ending of matching string for the url you want to get matched. so just replace the word page with 404. Final regex expression : ^/page\$
Gabbar
3#
 In case of url path /404 you will get a id in params hash with value = 404 otherwise you will get value of id is 95404 so here you can also check it like this: - redirect_url = params[:id] == 404 ? root_path : request.original_url