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':
|
2018-09-29 18:32:53 +08:00
|
|
|
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;
|