/** * 公開パスプレフィックス(ブラウザ URL)。PHP boot が window/globalThis に注入する。 * 既知の dual-docroot URL(/test・/ftp-preview)は location を優先し、 * 注入が空のまま別プレフィックス配下で配信されてもホーム判定がずれないようにする。 * 正式「/」は空文字。未注入かつ未知パスも ''。 */ (function (root) { 'use strict'; function inferPrefixFromLocation() { try { var path = typeof location !== 'undefined' && location.pathname != null ? String(location.pathname) : ''; if (path === '/ftp-preview' || path.indexOf('/ftp-preview/') === 0) return '/ftp-preview'; if (path === '/test' || path.indexOf('/test/') === 0) return '/test'; } catch (_e) {} return ''; } function getPublicPathPrefix() { var inferred = inferPrefixFromLocation(); if (inferred) return inferred; if (typeof root.__RAKUSUMO_PUBLIC_PATH_PREFIX__ === 'string') { return root.__RAKUSUMO_PUBLIC_PATH_PREFIX__; } return ''; } function publicSiteHref(segment) { var pre = getPublicPathPrefix(); var seg = String(segment == null ? '' : segment).replace(/^\/+|\/+$/g, ''); if (!seg) return pre === '' ? '/' : pre + '/'; return (pre === '' ? '' : pre) + '/' + seg + '/'; } function publicSiteAsset(path) { var pre = getPublicPathPrefix(); var p = String(path == null ? '' : path).replace(/^\/+/, ''); return (pre === '' ? '' : pre) + '/' + p; } root.RakusumoPublicPath = { getPrefix: getPublicPathPrefix, href: publicSiteHref, asset: publicSiteAsset, }; if (typeof module === 'object' && module.exports) { module.exports = root.RakusumoPublicPath; } })(typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : this);