encodeURI는 http://
와 같은 URI에 관련된 부분은 encoding하지 않음
하지만 encodeURIComponent는 그런거 상관없이 다 인코딩함.
URI 전체를 인코딩하는 경우(http://포함) -> encodeURI
URI 부분만을 인코딩하는 경우 -> encodeURIComponent
let entireURL = "http://www.naver.com/네이버"
console.log(encodeURI(entireURL));
//결과: http://www.naver.com/%EB%84%A4%EC%9D%B4%EB%B2%84
console.log(encodeURIComponent(entireURL));
//결과: http%3A%2F%2Fwww.naver.com%2F%EB%84%A4%EC%9D%B4%EB%B2%84
The difference between encodeURI and encodeURIComponent is encodeURIComponent encodes the entire string, where encodeURI ignores protocol prefix ('http://') and domain name. encodeURIComponent is designed to encode everything, where encodeURI ignores a URL's domain related roots.