2022-01-16 게시 됨2022-01-16 업데이트 됨web1분안에 읽기 (약 124 단어)encodeuricomponent vs encodeurimdn example1234567891011121314var set1 = ';,/?:@&=+$'; // Reserved Charactersvar set2 = "-_.!~*'()"; // Unescaped Charactersvar set3 = '#'; // Number Signvar set4 = 'ABC abc 123'; // Alphanumeric Characters + Spaceconsole.log(encodeURI(set1)); // ;,/?:@&=+$console.log(encodeURI(set2)); // -_.!~*'()console.log(encodeURI(set3)); // #console.log(encodeURI(set4)); // ABC%20abc%20123 (the space gets encoded as %20)console.log(encodeURIComponent(set1)); // %3B%2C%2F%3F%3A%40%26%3D%2B%24console.log(encodeURIComponent(set2)); // -_.!~*'()console.log(encodeURIComponent(set3)); // %23console.log(encodeURIComponent(set4)); // ABC%20abc%20123 (the space gets encoded as %20) 새롭게 url을 생성하는 과정에서는 encodeURIComponent를 쓰면될 것 같다 참고 https://stackoverflow.com/questions/4540753/should-i-use-encodeuri-or-encodeuricomponent-for-encoding-urls/4540785 https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent