diff --git a/packages/backend/src/routers/_default.js b/packages/backend/src/routers/_default.js index be5e2ad7..19045413 100644 --- a/packages/backend/src/routers/_default.js +++ b/packages/backend/src/routers/_default.js @@ -274,7 +274,7 @@ router.all('*', async function(req, res, next) { app_title = config.title; // /action/ - if(path.startsWith('/action/')){ + if(path.startsWith('/action/') || path.startsWith('/@')){ path = '/'; } // /app/ diff --git a/src/initgui.js b/src/initgui.js index 9622e7f8..a536c733 100644 --- a/src/initgui.js +++ b/src/initgui.js @@ -186,11 +186,35 @@ window.initgui = async function(options){ // will hold the result of the whoami API call 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/@ + //-------------------------------------------------------------------------------------- + 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 // i.e. https://puter.com/app/ //-------------------------------------------------------------------------------------- - const url_paths = window.location.pathname.split('/').filter(element => element); if(url_paths[0]?.toLocaleLowerCase() === 'app' && url_paths[1]){ window.app_launched_from_url = url_paths[1];