diff options
author | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2019-05-13 17:26:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-13 17:26:00 +0200 |
commit | 2246003a3e9de98abebf03410c71dd6c03ec8e95 (patch) | |
tree | 62a8d52940a502a647b767ad43e3176a1fbbbd49 /core/js/js.js | |
parent | 74ad4cce838172a51d441ffd53b7cae936f9dbb3 (diff) | |
parent | e3ae7dc11524bfe9c6f07305fa2761b54a8823bd (diff) | |
download | nextcloud-server-2246003a3e9de98abebf03410c71dd6c03ec8e95.tar.gz nextcloud-server-2246003a3e9de98abebf03410c71dd6c03ec8e95.zip |
Merge pull request #15516 from nextcloud/refactor/path-helpers-bundle
Move path helpers to the bundle
Diffstat (limited to 'core/js/js.js')
-rw-r--r-- | core/js/js.js | 129 |
1 files changed, 0 insertions, 129 deletions
diff --git a/core/js/js.js b/core/js/js.js index 4a7f035db61..127d293cd4c 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -82,39 +82,6 @@ Object.assign(window.OC, { }, /** - * get the absolute path to an image file - * if no extension is given for the image, it will automatically decide - * between .png and .svg based on what the browser supports - * @param {string} app the app id to which the image belongs - * @param {string} file the name of the image file - * @return {string} - */ - imagePath:function(app,file){ - if(file.indexOf('.')==-1){//if no extension is given, use svg - file+='.svg'; - } - return OC.filePath(app,'img',file); - }, - - /** - * URI-Encodes a file path but keep the path slashes. - * - * @param path path - * @return encoded path - */ - encodePath: function(path) { - if (!path) { - return path; - } - var parts = path.split('/'); - var result = []; - for (var i = 0; i < parts.length; i++) { - result.push(encodeURIComponent(parts[i])); - } - return result.join('/'); - }, - - /** * Loads translations for the given app asynchronously. * * @param {String} app app name @@ -126,102 +93,6 @@ Object.assign(window.OC, { }, /** - * Returns the base name of the given path. - * For example for "/abc/somefile.txt" it will return "somefile.txt" - * - * @param {String} path - * @return {String} base name - */ - basename: function(path) { - return path.replace(/\\/g,'/').replace( /.*\//, '' ); - }, - - /** - * Returns the dir name of the given path. - * For example for "/abc/somefile.txt" it will return "/abc" - * - * @param {String} path - * @return {String} dir name - */ - dirname: function(path) { - return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, ''); - }, - - /** - * Returns whether the given paths are the same, without - * leading, trailing or doubled slashes and also removing - * the dot sections. - * - * @param {String} path1 first path - * @param {String} path2 second path - * @return {bool} true if the paths are the same - * - * @since 9.0 - */ - isSamePath: function(path1, path2) { - var filterDot = function(p) { - return p !== '.'; - }; - var pathSections1 = _.filter((path1 || '').split('/'), filterDot); - var pathSections2 = _.filter((path2 || '').split('/'), filterDot); - path1 = OC.joinPaths.apply(OC, pathSections1); - path2 = OC.joinPaths.apply(OC, pathSections2); - return path1 === path2; - }, - - /** - * Join path sections - * - * @param {...String} path sections - * - * @return {String} joined path, any leading or trailing slash - * will be kept - * - * @since 8.2 - */ - joinPaths: function() { - if (arguments.length < 1) { - return ''; - } - var path = ''; - // convert to array - var args = Array.prototype.slice.call(arguments); - // discard empty arguments - args = _.filter(args, function(arg) { - return arg.length > 0; - }); - if (args.length < 1) { - return ''; - } - - var lastArg = args[args.length - 1]; - var leadingSlash = args[0].charAt(0) === '/'; - var trailingSlash = lastArg.charAt(lastArg.length - 1) === '/'; - var sections = []; - var i; - for (i = 0; i < args.length; i++) { - sections = sections.concat(args[i].split('/')); - } - var first = !leadingSlash; - for (i = 0; i < sections.length; i++) { - if (sections[i] !== '') { - if (first) { - first = false; - } else { - path += '/'; - } - path += sections[i]; - } - } - - if (trailingSlash) { - // add it back - path += '/'; - } - return path; - }, - - /** * Parses a URL query string into a JS map * @param {string} queryString query string in the format param1=1234¶m2=abcde¶m3=xyz * @return {Object.<string, string>} map containing key/values matching the URL parameters |