I have the following template with a table. An Array is traversed and a link is created in the row of the table
<tbody>
<%for(var i=0;i<resultados.length;i++){ %>
<tr onclick="window.open('#/ensayo/<%- resultados[i].tipoEnsayo %>/<%- resultados[i].idEnsayo %>', '_blank')" class="selectableRow">
<% if (mostrarResultados.mostrarTipoEnsayo == 1) { %><td><%- resultados[i].tipoEnsayo %></td><%}%>
<% if (mostrarResultados.mostrarIdEnsayo == 1) { %><td><%- resultados[i].idEnsayo %></td><%}%>
</tr>
<%}%>
If you click on the link, it will take you to another screen. The problem comes when the idEnsayo contains "%".
The URL that is formed is the following: http://localhost:8080/Petrocor/index_1.html#/ensayo/inmersion/EAutoclave_6%Mo-SS_1
Da error ( Uncaught URIError: URI malformed
) when forming the URL the encode of the character "%" is "% 25"
How can I escape this character when the URL is formed inside the html, with the underscore syntax?
In javascript it would be something like this:
var ensayo=resultados[i].idEnsayo;
if(ensayo.includes('%'){
ensayo=ensayo.replace('%','%25');
}