1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-03 07:55:36 +00:00
Files
seahub/frontend/src/utils/url-decorator.js

28 lines
771 B
JavaScript
Raw Normal View History

2018-09-29 15:47:53 +08:00
import {siteRoot, historyRepoID, fileServerRoot } from '../components/constants';
import { encodePath } from '../components/utils';
2018-09-12 17:01:48 +08:00
class URLDecorator {
static getUrl(options) {
let url = '';
let params = '';
switch (options.type) {
case 'download_historic_file':
params = 'p=' + options.filePath;
2018-09-29 15:47:53 +08:00
url = siteRoot + 'repo/' + historyRepoID + '/' + options.objID + '/download?' + params;
2018-09-12 17:01:48 +08:00
break;
2018-09-29 15:47:53 +08:00
case 'download_dir_zip_url':
url = fileServerRoot + 'zip/' + options.token;
2018-09-12 17:01:48 +08:00
break;
2018-09-29 15:47:53 +08:00
case 'download_file_url':
url = siteRoot + 'lib/' + options.repoID + '/file' + encodePath(options.filePath) + '?dl=1';
2018-09-12 17:01:48 +08:00
break;
default:
url = '';
break;
}
return url;
}
}
export default URLDecorator;