A html space is showing as instead of

前端 未结 5 643
自闭症患者
自闭症患者 2020-11-29 02:39

Passing a filename to the firefox browser causes it to replace spaces with %2520 instead of %20.

I have the following HTML in a file calle

5条回答
  •  情话喂你
    2020-11-29 03:01

    The following code snippet resolved my issue. Thought this might be useful to others.

    var strEnc = this.$.txtSearch.value.replace(/\s/g, "-");
    strEnc = strEnc.replace(/-/g, " ");

    Rather using default encodeURIComponent my first line of code is converting all spaces into hyphens using regex pattern /\s\g and the following line just does the reverse, i.e. converts all hyphens back to spaces using another regex pattern /-/g. Here /g is actually responsible for finding all matching characters.

    When I am sending this value to my Ajax call, it traverses as normal spaces or simply %20 and thus gets rid of double-encoding.

提交回复
热议问题