mirror of
https://github.com/HeyPuter/puter
synced 2024-11-15 06:15:47 +00:00
Make GUI open the relavant directory when URL is provided
This commit is contained in:
parent
c1647a5982
commit
581964b655
@ -274,7 +274,7 @@ router.all('*', async function(req, res, next) {
|
|||||||
app_title = config.title;
|
app_title = config.title;
|
||||||
|
|
||||||
// /action/
|
// /action/
|
||||||
if(path.startsWith('/action/')){
|
if(path.startsWith('/action/') || path.startsWith('/@')){
|
||||||
path = '/';
|
path = '/';
|
||||||
}
|
}
|
||||||
// /app/
|
// /app/
|
||||||
|
@ -186,11 +186,35 @@ window.initgui = async function(options){
|
|||||||
// will hold the result of the whoami API call
|
// will hold the result of the whoami API call
|
||||||
let whoami;
|
let whoami;
|
||||||
|
|
||||||
|
const url_paths = window.location.pathname.split('/').filter(element => element);
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
// Trying to view a user's public folder?
|
||||||
|
// i.e. https://puter.com/@<username>
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
if(url_paths[0]?.startsWith('@')){
|
||||||
|
let username = url_paths[0].substring(1);
|
||||||
|
let item_path = '/' + username + '/Public';
|
||||||
|
|
||||||
|
// check if username has valid characters
|
||||||
|
if(!username.match(/^[a-z0-9_]+$/i)){
|
||||||
|
UIAlert({
|
||||||
|
message: 'Invalid username.'
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
UIWindow({
|
||||||
|
path: item_path,
|
||||||
|
title: path.basename(item_path),
|
||||||
|
icon: await window.item_icon({is_dir: true, path: item_path}),
|
||||||
|
is_dir: true,
|
||||||
|
app: 'explorer',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// Determine if an app was launched from URL
|
// Determine if an app was launched from URL
|
||||||
// i.e. https://puter.com/app/<app_name>
|
// i.e. https://puter.com/app/<app_name>
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const url_paths = window.location.pathname.split('/').filter(element => element);
|
|
||||||
if(url_paths[0]?.toLocaleLowerCase() === 'app' && url_paths[1]){
|
if(url_paths[0]?.toLocaleLowerCase() === 'app' && url_paths[1]){
|
||||||
window.app_launched_from_url = url_paths[1];
|
window.app_launched_from_url = url_paths[1];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user