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

36 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-05-15 14:56:46 +08:00
import { siteRoot, historyRepoID } from './constants';
import { Utils } from './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':
2021-08-31 11:28:39 +08:00
params = 'p=' + Utils.encodePath(options.filePath);
url = siteRoot + 'repo/' + historyRepoID + '/' + options.objID + '/download?' + params;
break;
case 'download_file_url':
url = siteRoot + 'lib/' + options.repoID + '/file' + Utils.encodePath(options.filePath) + '?dl=1';
break;
case 'file_revisions':
params = 'p=' + Utils.encodePath(options.filePath);
url = siteRoot + 'repo/file_revisions/' + options.repoID + '/?' + params;
break;
case 'open_via_client':
url = 'seafile://openfile?repo_id=' + options.repoID + '&path=' + Utils.encodePath(options.filePath);
break;
case 'draft_view':
url = siteRoot + 'lib/' + options.repoID + '/file' + options.filePath + '?mode=edit&draft_id=' + options.draftId;
break;
default:
url = '';
break;
2018-09-12 17:01:48 +08:00
}
return url;
}
}
export default URLDecorator;