mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 23:20:51 +00:00
optimized path check method (#2846)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { mediaUrl, gettext } from './constants';
|
||||
import { mediaUrl, gettext, siteRoot } from './constants';
|
||||
import { strChineseFirstPY } from './pinyin-by-unicode';
|
||||
|
||||
export const Utils = {
|
||||
@@ -389,6 +389,31 @@ export const Utils = {
|
||||
}
|
||||
},
|
||||
|
||||
isInternalMarkdownLink: function(url, repoID) {
|
||||
var re = new RegExp(siteRoot + 'lib/' + repoID + '.*\.md$');
|
||||
return re.test(url);
|
||||
},
|
||||
|
||||
isInternalDirLink: function(url, repoID) {
|
||||
var re = new RegExp(siteRoot + 'library/' + repoID + '.*');
|
||||
return re.test(url);
|
||||
},
|
||||
|
||||
getPathFromInternalMarkdownLink: function(url, repoID) {
|
||||
var re = new RegExp(siteRoot + 'lib/' + repoID + '/file' + '(.*\.md)');
|
||||
var array = re.exec(url);
|
||||
var path = decodeURIComponent(array[1]);
|
||||
return path;
|
||||
},
|
||||
|
||||
getPathFromInternalDirLink: function(url, repoID, repoName) {
|
||||
var re = new RegExp(siteRoot + 'library/' + repoID + '/' + repoName + '(/.*)');
|
||||
var array = re.exec(url);
|
||||
var path = decodeURIComponent(array[1]);
|
||||
|
||||
return path;
|
||||
},
|
||||
|
||||
compareTwoWord: function(wordA, wordB) {
|
||||
// compare wordA and wordB at lower case
|
||||
// if wordA >= wordB, return 1
|
||||
|
Reference in New Issue
Block a user