로그인 페이지에서 Shared Box URL 추출하기
발행: (2026년 1월 19일 오후 07:23 GMT+9)
2 min read
원문: Dev.to
Source: Dev.to
Windows에서 Box 파일 링크를 열면 브라우저가 공유된 콘텐츠로 바로 이동하는 대신 Box 로그인 페이지로 리다이렉트될 수 있습니다. 로그인 페이지 URL에는 원래 목적지 URL을 포함하는 쿼리 파라미터가 들어 있는 경우가 많습니다. 이 스니펫은 해당 목적지 URL을 추출해 클립보드에 복사하여 공유 가능한 링크를 빠르게 복구할 수 있게 해줍니다.
JavaScript snippet
(function () {
const hostOrig = location.host;
// Skip if host does not end with box.com
if (!hostOrig.endsWith('box.com')) return;
const usp = new URLSearchParams(location.search);
const path = usp.get('redirect_url');
// Skip if redirect_url is missing or empty
if (!path) return;
const host = hostOrig
.split('.')
.filter((part) => part !== 'account')
.join('.');
// If redirect_url is an absolute URL, use it as‑is; otherwise build https://{host}{path}
const url = 'https://' + host + path;
const tempTextarea = document.createElement('textarea');
tempTextarea.textContent = url;
document.body.appendChild(tempTextarea);
tempTextarea.select();
document.execCommand('copy');
document.body.removeChild(tempTextarea);
})();
Bookmarklet
javascript:!function(){const hostOrig=location.host;if(!hostOrig.endsWith("box.com"))return;const path=new URLSearchParams(location.search).get("redirect_url");if(!path)return;const url="https://"+hostOrig.split(".").filter(part=>"account"!==part).join(".")+path;const tempTextarea=document.createElement("textarea");tempTextarea.textContent=url;document.body.appendChild(tempTextarea);tempTextarea.select();document.execCommand("copy");document.body.removeChild(tempTextarea)}();
How it works
- Parse the query string using
URLSearchParamsto read parameters on the current page. - Extract
redirect_urlto obtain the path (or full redirect target) that Box stored when it sent you to the login flow. - Rebuild the host name by removing the
accountsubdomain (common on Box login pages) so the destination points to the main Box domain. - Construct the final URL by combining
https://, the adjusted host, and the redirect path. - Copy the result to the clipboard by temporarily creating a
<textarea>, selecting its contents, and executing the copy command. - Clean up by removing the temporary element from the page.
Using this approach, you can recover a share‑ready URL directly from the Box login screen without manually decoding or editing the address bar.