mirror of
https://github.com/HeyPuter/puter
synced 2024-11-15 06:15:47 +00:00
Add robust hostname comparison for when declaring an environment as GUI
This commit is contained in:
parent
30f17ade3a
commit
378b87459a
@ -69,11 +69,24 @@ window.puter = (function() {
|
|||||||
else
|
else
|
||||||
this.env = 'web';
|
this.env = 'web';
|
||||||
|
|
||||||
// there are some specific situations where puter is definitely loaded in GUI mode
|
// There are some specific situations where puter is definitely loaded in GUI mode
|
||||||
// we're going to check for those situations here so that we don't break anything unintentionally
|
// we're going to check for those situations here so that we don't break anything unintentionally
|
||||||
// if navigator URL's hostname is 'puter.com'
|
// if navigator URL's hostname is 'puter.com'
|
||||||
if(window.location.hostname === 'puter.com'){
|
if(this.env !== 'gui'){
|
||||||
this.env = 'gui';
|
// Retrieve the hostname from the URL: Remove the trailing dot if it exists. This is to handle the case where the URL is, for example, `https://puter.com.` (note the trailing dot).
|
||||||
|
// This is necessary because the trailing dot can cause the hostname to not match the expected value.
|
||||||
|
let hostname = location.hostname.replace(/\.$/, '');
|
||||||
|
|
||||||
|
// Create a new URL object with the URL string
|
||||||
|
const url = new URL(this.defaultGUIOrigin);
|
||||||
|
|
||||||
|
// Extract hostname from the URL object
|
||||||
|
const gui_hostname = url.hostname;
|
||||||
|
|
||||||
|
// If the hostname matches the GUI hostname, then the SDK is running in the GUI environment
|
||||||
|
if(hostname === gui_hostname){
|
||||||
|
this.env = 'gui';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the 'args' from the URL. This is used to pass arguments to the app.
|
// Get the 'args' from the URL. This is used to pass arguments to the app.
|
||||||
|
@ -36,7 +36,6 @@ import PuterDialog from './UI/PuterDialog.js';
|
|||||||
import determine_active_container_parent from './helpers/determine_active_container_parent.js';
|
import determine_active_container_parent from './helpers/determine_active_container_parent.js';
|
||||||
import { ThemeService } from './services/ThemeService.js';
|
import { ThemeService } from './services/ThemeService.js';
|
||||||
import { BroadcastService } from './services/BroadcastService.js';
|
import { BroadcastService } from './services/BroadcastService.js';
|
||||||
import UIWindowTaskManager from './UI/UIWindowTaskManager.js';
|
|
||||||
import { ProcessService } from './services/ProcessService.js';
|
import { ProcessService } from './services/ProcessService.js';
|
||||||
import { PROCESS_RUNNING } from './definitions.js';
|
import { PROCESS_RUNNING } from './definitions.js';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user