@@ -49,6 +49,7 @@ import { AntiCSRFService } from './services/AntiCSRFService.js';
49
49
import { IPCService } from './services/IPCService.js' ;
50
50
import { ExecService } from './services/ExecService.js' ;
51
51
import { DebugService } from './services/DebugService.js' ;
52
+ import { privacy_aware_path } from './util/desktop.js' ;
52
53
53
54
const launch_services = async function ( options ) {
54
55
// === Services Data Structures ===
@@ -1461,35 +1462,5 @@ $(document).on('contextmenu', '.disable-context-menu', function(e){
1461
1462
}
1462
1463
} )
1463
1464
1464
- /**
1465
- * Converts a file system path to a privacy-aware path.
1466
- * - Paths starting with `~/` are returned unchanged.
1467
- * - Paths starting with the user's home path are replaced with `~`.
1468
- * - Absolute paths not starting with the user's home path are returned unchanged.
1469
- * - Relative paths are prefixed with `~/`.
1470
- * - Other paths are returned unchanged.
1471
- *
1472
- * @param {string } fspath - The file system path to be converted.
1473
- * @returns {string } The privacy-aware path.
1474
- */
1475
- window . privacy_aware_path = function ( fspath ) {
1476
- // e.g. /my_username/test.txt -> ~/test.txt
1477
- if ( fspath . startsWith ( '~/' ) )
1478
- return fspath ;
1479
- // e.g. /my_username/test.txt -> ~/test.txt
1480
- else if ( fspath . startsWith (
1481
- window . home_path . endsWith ( '/' )
1482
- ? window . home_path
1483
- : window . home_path + '/'
1484
- ) )
1485
- return fspath . replace ( window . home_path , '~' ) ;
1486
- // e.g. /other_username/test.txt -> /other_username/test.txt
1487
- else if ( fspath . startsWith ( '/' ) && ! fspath . startsWith ( window . home_path ) )
1488
- return fspath ;
1489
- // e.g. test.txt -> ~/test.txt
1490
- else if ( ! fspath . startsWith ( '/' ) )
1491
- return '~/' + fspath ;
1492
- // e.g. /username/path/to/item -> /username/path/to/item
1493
- else
1494
- return fspath ;
1495
- } ;
1465
+ // util/desktop.js
1466
+ window . privacy_aware_path = privacy_aware_path ( { window } ) ;
0 commit comments