Avoid special characters on routes

0

I am building a filter for a project, one of the filters is filled with this arrangement:

this.grupoHorario = ['Todos', 'Madrugada', 'Mañana', 'Tarde', 'Noche'];

When the user selects Tomorrow the route that the console shows me is the following:

  

link Ma% C3% B1ana

Some solution so that the filter option continues to leave Tomorrow but the URL does not code the special character.
This would be a good solution but I can not find the way.

  

link Manana

EDITED
HTML

<div>
   <label>Grupo horario:</label>
     <div class="form-group">
       <ng-select [allowClear]="true" [items]="grupoHorario" 
         (selected)="seleccionarGrupoHorario($event)" placeholder="Seleccione">
       </ng-select>
     </div>
  </div>

Funcion seleccionarGrupoHorario()
  seleccionarGrupoHorario(valor: any): void {
    this.valorGrupoHorario= valor;
}  

Then it is saved in the localStorage

this.myLocalStorageService.setItem(Items.GRUPO_HORARIO, this.valorGrupoHorario);  

And then the URL is built by calling elements from the localStorage

let grupoHorario= this.myLocalStorageService.getItem(Items.GRUPO_HORARIO);  
let globalUrl = "?fechaInicio=" + fechaInicio + "&fechaFin=" + fechaFn + "&grupoHorario=" + grupoHorario
    
asked by warner 21.03.2018 в 18:06
source

1 answer

0

Sorry but it's not possible to show Tomorrow in the url and if you want to see Manana instead of Tomorrow I think you can do it yourself considering that you did not give us the code that reads the filters.

In what I can help you is guiding you with this theme, when you send a string with special characters or reserved characters , what you must do is to first code the string with one of the following methods of javascript:

var str = "Mañana";
var strParaEnviar = encodeUri(str); // decodificador -> decodeURI(str) 
// o encoeURIComponent(str); decodificador decodeURIComponent(str)
// o escape(str); decodificador unescape(str); 

You should also know that if you are going to read this on the server side, you must decode it according to the encoding you used, each language has its own decoder but all have decoders for these methods.

    
answered by 21.03.2018 в 18:54