mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
22 lines
535 B
JavaScript
22 lines
535 B
JavaScript
|
|
import {clipboard} from 'electron';
|
||
|
|
|
||
|
|
const getPath = platform => {
|
||
|
|
switch (platform) {
|
||
|
|
case 'darwin': {
|
||
|
|
const filepath = clipboard.read('public.file-url');
|
||
|
|
return filepath.replace('file://', '');
|
||
|
|
}
|
||
|
|
case 'win32': {
|
||
|
|
const filepath = clipboard.read('FileNameW');
|
||
|
|
return filepath.replace(new RegExp(String.fromCharCode(0), 'g'), '');
|
||
|
|
}
|
||
|
|
// linux already pastes full path
|
||
|
|
default:
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
export default function processClipboard() {
|
||
|
|
return getPath(process.platform);
|
||
|
|
}
|