1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 07:27:04 +00:00
Files
seahub/frontend/src/utils/url-decorator.js
shanshuirenjia c0d645962f Optimized code structure (#2430)
* combine utils file

* modify file position
2018-10-09 10:56:59 +08:00

28 lines
748 B
JavaScript

import {siteRoot, historyRepoID, fileServerRoot } from './constants';
import { Utils } from './utils';
class URLDecorator {
static getUrl(options) {
let url = '';
let params = '';
switch (options.type) {
case 'download_historic_file':
params = 'p=' + options.filePath;
url = siteRoot + 'repo/' + historyRepoID + '/' + options.objID + '/download?' + params;
break;
case 'download_dir_zip_url':
url = fileServerRoot + 'zip/' + options.token;
break;
case 'download_file_url':
url = siteRoot + 'lib/' + options.repoID + '/file' + Utils.encodePath(options.filePath) + '?dl=1';
break;
default:
url = '';
break;
}
return url;
}
}
export default URLDecorator;