라이브러리
[JAVASCRIPT] decodeURIComponent(uriComponent) - URI의 개별 구성 요소를 디코딩
URI Component Decode
URI Component Decode는 URL의 컴포넌트를 디코딩하는 데 사용되는 JavaScript 함수입니다. 이 함수는 URL의 컴포넌트를 디코딩하여 원래의 문자열로 변환합니다.
decodeURIComponent(uriComponent) 함수
decodeURIComponent(uriComponent) 함수는 URI Component를 디코딩하는 데 사용됩니다. 이 함수는 URL의 컴포넌트를 디코딩하여 원래의 문자열로 변환합니다.
# 예제
#hostingforum.kr
javascript
// URL의 컴포넌트를 디코딩하는 예제
const uriComponent = encodeURIComponent("Hello, World!");
console.log(uriComponent); // Output: Hello%2C%20World%21
const decodedComponent = decodeURIComponent(uriComponent);
console.log(decodedComponent); // Output: Hello, World!
위 예제에서, `encodeURIComponent` 함수는 "Hello, World!" 문자열을 URL의 컴포넌트로 디코딩합니다. 그런 다음, `decodeURIComponent` 함수는 디코딩된 컴포넌트를 원래의 문자열로 변환합니다.
# URL 디코딩 예제
#hostingforum.kr
javascript
// URL 디코딩 예제
const url = "https://example.com/path/to/resource?param1=value1¶m2=value2";
const decodedUrl = decodeURIComponent(url);
console.log(decodedUrl); // Output: https://example.com/path/to/resource?param1=value1¶m2=value2
위 예제에서, `decodeURIComponent` 함수는 URL을 디코딩하여 원래의 문자열로 변환합니다.
# URLSearchParams 디코딩 예제
#hostingforum.kr
javascript
// URLSearchParams 디코딩 예제
const url = "https://example.com/path/to/resource?param1=value1¶m2=value2";
const urlSearchParams = new URLSearchParams(url);
const decodedSearchParams = decodeURIComponent(urlSearchParams.toString());
console.log(decodedSearchParams); // Output: param1=value1¶m2=value2
위 예제에서, `URLSearchParams` 객체를 사용하여 URL의 파라미터를 디코딩합니다. 그런 다음, `decodeURIComponent` 함수를 사용하여 디코딩된 파라미터를 원래의 문자열로 변환합니다.
결론
decodeURIComponent(uriComponent) 함수는 URL의 컴포넌트를 디코딩하는 데 사용되는 JavaScript 함수입니다. 이 함수는 URL의 컴포넌트를 디코딩하여 원래의 문자열로 변환합니다. 예제를 통해 이 함수의 사용법을 살펴보았습니다.
댓글목록
등록된 댓글이 없습니다.