diff options
Diffstat (limited to 'lib/private/share/helper.php')
-rw-r--r-- | lib/private/share/helper.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/private/share/helper.php b/lib/private/share/helper.php index 6059af0196d..55b71ceeeac 100644 --- a/lib/private/share/helper.php +++ b/lib/private/share/helper.php @@ -221,4 +221,34 @@ class Helper extends \OC\Share\Constants { return $expires; } + + /** + * Extracts the necessary remote name from a given link + * + * Strips away a potential file name, to allow + * - user + * - user@localhost + * - user@http://localhost + * - user@http://localhost/ + * - user@http://localhost/index.php + * - user@http://localhost/index.php/s/{shareToken} + * + * @param string $shareWith + * @return string + */ + public static function fixRemoteURLInShareWith($shareWith) { + if (strpos($shareWith, '@')) { + list($user, $remote) = explode('@', $shareWith, 2); + + $remote = str_replace('\\', '/', $remote); + if ($fileNamePosition = strpos($remote, '/index.php')) { + $remote = substr($remote, 0, $fileNamePosition); + } + $remote = rtrim($remote, '/'); + + $shareWith = $user . '@' . $remote; + } + + return rtrim($shareWith, '/'); + } } |