file: honor server's remote-root option (remove root path from displayed path and returned value)
This commit is contained in:
parent
9ef97ca1c3
commit
4dbc572ea1
4 changed files with 17 additions and 7 deletions
|
|
@ -9,6 +9,8 @@
|
|||
- the html property is no longer restricted / sanitized
|
||||
- input/textarea/select no longer have their appearance property reset in custom html
|
||||
- canvas: added `contextType` property
|
||||
- file: honor server's `remote-root` option (remove root path from displayed path and returned value)
|
||||
|
||||
|
||||
- scripting
|
||||
- user scripts are longer protected against infinite loop and the main window object may be reached (it's not supported to break out of scripting context, but resources are no longer wasted to prevent it)
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ export default function UiFilebrowser(options, callback) {
|
|||
`
|
||||
|
||||
var files = [],
|
||||
root = '',
|
||||
path = ''
|
||||
|
||||
var extRe = options.extension ? new RegExp('.*\\.' + options.extension + '$') : /.*/
|
||||
|
|
@ -75,10 +76,10 @@ export default function UiFilebrowser(options, callback) {
|
|||
if (files.some(x=>x.name===saveInput.value)) {
|
||||
if (!confirm(locales('remotesave_overwrite'))) return
|
||||
}
|
||||
callback([path, saveInput.value])
|
||||
callback([path, saveInput.value], root)
|
||||
popup.close()
|
||||
} else {
|
||||
callback([path, choice ? choice.value : ''])
|
||||
callback([path, choice ? choice.value : ''], root)
|
||||
popup.close()
|
||||
}
|
||||
}
|
||||
|
|
@ -142,11 +143,13 @@ export default function UiFilebrowser(options, callback) {
|
|||
|
||||
ipc.on('listDir', (data)=>{
|
||||
|
||||
ariane.textContent = path = data.path
|
||||
path = data.path
|
||||
root = data.root
|
||||
|
||||
ariane.textContent = path.replace(root, '/')
|
||||
|
||||
files = data.files.filter(x=>x.folder || x.name.match(extRe))
|
||||
|
||||
|
||||
function alphaSort(a, b){
|
||||
// convert to strings and force lowercase
|
||||
a = typeof a.name === 'string' ? a.name.toLowerCase() : a.name.toString()
|
||||
|
|
|
|||
|
|
@ -58,9 +58,13 @@ export default class File extends Widget {
|
|||
directory: this.getProp('directory') === 'auto' ? undefined : this.getProp('directory'),
|
||||
loadDir: this.getProp('allowDir'),
|
||||
save: this.getProp('mode') === 'save'
|
||||
}, (path)=>{
|
||||
}, (path, root)=>{
|
||||
|
||||
this.setValue(path.join(path[0][0] === '/' ? '/' : '\\'), {
|
||||
var sep = path[0][0] === '/' ? '/' : '\\',
|
||||
val = path.join(sep)
|
||||
if (root) val = val.replace(root, sep).replace(sep + sep, sep)
|
||||
|
||||
this.setValue(val, {
|
||||
sync: true,
|
||||
send: true
|
||||
})
|
||||
|
|
|
|||
|
|
@ -567,7 +567,8 @@ export default class Callbacks {
|
|||
list = list.filter(x=>x.folder || x.name.match(extRe))
|
||||
this.ipcServer.send('listDir', {
|
||||
path: p,
|
||||
files: list
|
||||
files: list,
|
||||
root: root
|
||||
}, clientId)
|
||||
settings.write('last-dir', p, false, false)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue