mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-06 16:32:31 +01:00
fix (#210): properly handle file/folder names
This commit is contained in:
parent
44310fbab0
commit
ae2ef413b3
4 changed files with 20 additions and 7 deletions
|
|
@ -132,11 +132,21 @@ export class PathElementWrapper extends React.Component {
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
let className = "component_path-element-wrapper";
|
let className = "component_path-element-wrapper";
|
||||||
if(this.props.highlight) { className += " highlight";}
|
if(this.props.highlight) { className += " highlight"; }
|
||||||
|
|
||||||
|
let href = "/files" + (this.props.path.full || "")
|
||||||
|
href = href
|
||||||
|
.replace(/\%/g, "%2525") // Hack to get the Link Component to work
|
||||||
|
// See ExistingThing in 'thing-existing.js'
|
||||||
|
.replace(/#/g, "%23")
|
||||||
|
.replace(/\?/g, "%3F");
|
||||||
|
href = href || "/"
|
||||||
|
href += location.search;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li className={className}>
|
<li className={className}>
|
||||||
<NgIf cond={this.props.isLast === false}>
|
<NgIf cond={this.props.isLast === false}>
|
||||||
<Link to={"/files" + ((this.props.path.full || "").replace(/#/g, "%23") || "/") + location.search} className="label">
|
<Link to={href} className="label">
|
||||||
<NgIf cond={this.props.path.minify !== true}>
|
<NgIf cond={this.props.path.minify !== true}>
|
||||||
{this.limitSize(this.props.path.label)}
|
{this.limitSize(this.props.path.label)}
|
||||||
</NgIf>
|
</NgIf>
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ class FileSystem{
|
||||||
|
|
||||||
_ls_from_http(path, show_hidden){
|
_ls_from_http(path, show_hidden){
|
||||||
const url = appendShareToUrl("/api/files/ls?path="+prepare(path));
|
const url = appendShareToUrl("/api/files/ls?path="+prepare(path));
|
||||||
|
|
||||||
return http_get(url).then((response) => {
|
return http_get(url).then((response) => {
|
||||||
response = fileMiddleware(response, path, show_hidden);
|
response = fileMiddleware(response, path, show_hidden);
|
||||||
|
|
||||||
|
|
@ -93,7 +92,7 @@ class FileSystem{
|
||||||
}
|
}
|
||||||
this.obs.next(_err);
|
this.obs.next(_err);
|
||||||
return Promise.reject(err);
|
return Promise.reject(err);
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
_ls_from_cache(path, _record_access = false){
|
_ls_from_cache(path, _record_access = false){
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ export class FilesPage extends React.Component {
|
||||||
this.props.history.push(props.match.url + "/");
|
this.props.history.push(props.match.url + "/");
|
||||||
}
|
}
|
||||||
this.state = {
|
this.state = {
|
||||||
path: props.match.url.replace("/files", "").replace(/%23/g, "#") || "/",
|
path: (decodeURIComponent(location.pathname).replace("/files", "") || "/" ),
|
||||||
sort: settings_get("filespage_sort") || "type",
|
sort: settings_get("filespage_sort") || "type",
|
||||||
sort_reverse: true,
|
sort_reverse: true,
|
||||||
show_hidden: settings_get("filespage_show_hidden") || CONFIG["display_hidden"],
|
show_hidden: settings_get("filespage_show_hidden") || CONFIG["display_hidden"],
|
||||||
|
|
@ -96,7 +96,7 @@ export class FilesPage extends React.Component {
|
||||||
if(/\/$/.test(path) === false){ path = path + "/"; }
|
if(/\/$/.test(path) === false){ path = path + "/"; }
|
||||||
if(/^\//.test(path) === false){ path = "/"+ path; }
|
if(/^\//.test(path) === false){ path = "/"+ path; }
|
||||||
return path;
|
return path;
|
||||||
}((nextProps.match.params.path || "").replace(/%23/g, "#"));
|
}((nextProps.match.params.path || "").replace(/%23/g, "#").replace(/%3F/g, "?").replace(/%25/g, "%"));
|
||||||
if(new_path !== this.state.path){
|
if(new_path !== this.state.path){
|
||||||
this.setState({path: new_path, loading: true});
|
this.setState({path: new_path, loading: true});
|
||||||
this.onRefresh(new_path);
|
this.onRefresh(new_path);
|
||||||
|
|
|
||||||
|
|
@ -240,7 +240,11 @@ export class ExistingThing extends React.Component {
|
||||||
}
|
}
|
||||||
className = className.trim();
|
className = className.trim();
|
||||||
|
|
||||||
let fileLink = this.props.file.link.replace(/%2F/g, '/');
|
let fileLink = this.props.file.link
|
||||||
|
.replace(/%2F/g, "/")
|
||||||
|
.replace(/\%/g, "%2525") // Hack to get the Link Component to work
|
||||||
|
.replace(/\?/g, "%3F")
|
||||||
|
.replace(/\#/g, "%23");
|
||||||
|
|
||||||
return connectDragSource(connectDropNativeFile(connectDropFile(
|
return connectDragSource(connectDropNativeFile(connectDropFile(
|
||||||
<div className={"component_thing view-"+this.props.view+(this.props.selected === true ? " selected" : " not-selected")}>
|
<div className={"component_thing view-"+this.props.view+(this.props.selected === true ? " selected" : " not-selected")}>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue