forked from phcode-dev/staging.phcode.dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconstants.js
More file actions
1 lines (1 loc) · 1.93 KB
/
Copy pathconstants.js
File metadata and controls
1 lines (1 loc) · 1.93 KB
1
define(function(require,exports,module){const LEGACY_ORIGIN="https://phcode.dev",NEW_ORIGIN="https://web.phcode.dev",NEW_DOMAIN_NAME="web.phcode.dev",MIGRATION_DONE_KEY="migrateAssist.v1.done",MIGRATION_ATTEMPTS_KEY="migrateAssist.v1.attempts",MAX_AUTO_ATTEMPTS=2,ORIGINS_OVERRIDE_KEY="MIGRATE_ORIGINS_OVERRIDE";let _override=null;function _getOverride(){if(_override)return _override;if(_override={},Phoenix.isTestWindow||!Phoenix.config||"dev"!==Phoenix.config.environment)return _override;try{const parsed=JSON.parse(localStorage.getItem(ORIGINS_OVERRIDE_KEY));parsed&&"string"==typeof parsed.legacy&&"string"==typeof parsed.target&&(_override=parsed,console.log("MigrateAssist: using dev origin override",_override))}catch(e){console.warn("MigrateAssist: could not read origin override, using defaults",e)}return _override}function getLegacyOrigin(){return _getOverride().legacy||LEGACY_ORIGIN}function getNewOrigin(){return _getOverride().target||NEW_ORIGIN}function isLegacyOrigin(){return!Phoenix.isNativeApp&&location.origin===getLegacyOrigin()}function isNewOrigin(){return!Phoenix.isNativeApp&&location.origin===getNewOrigin()}function getLegacyDomainName(){return new URL(getLegacyOrigin()).hostname}function getMigrateAssistURL(){const pathname=location.pathname,prefix=pathname.substring(0,pathname.lastIndexOf("/")+1);return`${getLegacyOrigin()}${prefix}migrateAssist.html`}function isMigrationSupportedBrowser(){return!(Phoenix.browser.desktop.isSafari||Phoenix.browser.mobile.isIos)}exports.NEW_DOMAIN_NAME=NEW_DOMAIN_NAME,exports.MIGRATION_DONE_KEY=MIGRATION_DONE_KEY,exports.MIGRATION_ATTEMPTS_KEY=MIGRATION_ATTEMPTS_KEY,exports.MAX_AUTO_ATTEMPTS=2,exports.getLegacyOrigin=getLegacyOrigin,exports.getMigrateAssistURL=getMigrateAssistURL,exports.getLegacyDomainName=getLegacyDomainName,exports.getNewOrigin=getNewOrigin,exports.isLegacyOrigin=isLegacyOrigin,exports.isNewOrigin=isNewOrigin,exports.isMigrationSupportedBrowser=isMigrationSupportedBrowser});