예 - URL에서 오리진: https://www.example.com 이 URL에는 포트(Port)가 없습니다.
예 - URL에서 오리진: https://www.example.com:8080 이 URL에는 포트(Port)가 8080입니다.
예 - URL에서 오리진: http://localhost:3000 이 URL에는 포트(Port)가 3000입니다.
/* 전체 URL 예: https://www.example.com/products/list?page=1#review */
console.log(location.origin); // console.log(window.location.origin)과 동일
// 출력: "https://www.example.com"

/* 전체 URL 예: https://codingeverybody.kr/category/javascript/ */
console.log(location.origin); // console.log(window.location.origin)과 동일
// 출력: "https://codingeverybody.kr"
/* 현재 전체 URL 예: https://www.example.com/products/list?page=1#review */

// 현재 오리진 뒤에 이동할 경로를 붙여 새로운 URL 생성
const loginCallbackUrl = location.origin + "/login-callback.html";

console.log(loginCallbackUrl); 
// 출력: "https://codingeverybody.kr/login-callback.html"
/* 현재 전체 URL 예: https://www.example.com/products/list?page=1#review */
const facebookUrl = "https://www.facebook.com/sharer/sharer.php?u=";
const shareUrl = facebookUrl + encodeURIComponent(location.origin + "/products/list?page=1");

console.log(shareUrl);
// 출력: "https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fwww.example.com%2Fproducts%2Flist%3Fpage%3D1"