Transfer parameter passing between javascript Url pit, base64 parameters, and url parameters

It will escape special characters in the url parameter passing, so that needs to be processed through mass participation base64

Simply use under base64

1, installed in the project root directory

JS-Base64 --save install npm
2, introduced in the project file

let Base64 = require('js-base64').Base64

import { Base64 } from "js-base64";

3, used in the project file

Base64.encode ( 'Daewon') // fdsfds5f34
Base64.decode ( 'fdsfds5f34') // Daewon

Simple pit point

My solution

 

 

 

urlSwitchBase64 (wantData) {
       if (wantData.includes ( "% 2B" )) { 
        wantData = wantData.replace (/ \ + / g, "% 2B" ); 
      } 
      If (wantData.includes ( "% 20" )) { 
        wantData = wantData.replace (/ \ / g, "% 20" ); 
      } 
      If (wantData.includes ( "% 2F" )) { 
        wantData = wantData.replace (/ \ // g, "% 2F" ); 
      } 
      If (wantData.includes ( "% 25" )) { 
        wantData = wantData.replace (/ \% / g, "% 25" ); 
      } 
      If (wantData. = wantData.replace (/ \? / g, "% 26" ); 
      } 
      If (wantData.includes ( "3D" )) { 
        wantData = wantData.replace (/ \ = / g, "3D" ); 
      } 
      If (wantData.includes ( "% 23" )) { 
        wantData = wantData.replace (/ \ # / g, "% 23" ); 
      } 
      Return wantData; 
    }

Reference: https://blog.csdn.net/hanzl1/article/details/79282133?utm_source=blogxgwz9

Guess you like

Origin www.cnblogs.com/cqy1125/p/12571152.html