0
I have to edit an incoming URL, but in some cases the URL may contain an external reference with http
and it breaks my system, because it only accepted paths to its own platform.
Follow a code snippet and some outputs:
<%-object.each do |o| -%>
<%- url = @context.nil? ? polymorphic_path([ :adm, o]) : polymorphic_path([ :adm, @context, o])-%>
Some exits:
<%= o -%> = #<Collection:0x7f068b067870>
<%= @context.nil? -%> = true
<%= polymorphic_path([ :adm, o]) -%> = /admin/pagina/biblioteca
Here’s my mistake, sometimes this link can be external, and when concatenates I can’t make it work:
<%= polymorphic_path([ :adm, o]) -%> = /admin/pagina/https://livraria.com
I believe that this return of the variable url
is a String.
You can inspect the value of the variable "the" ?
– Luiz Carvalho
I have already solved, the variable "url" has a string as return and ruby accepts regular expressions. soon post the Regex used.
– Pedro PH Henrique