From aa1bf42ccc2f2182bcb08a98cdd19f9b84459a1a Mon Sep 17 00:00:00 2001 From: huangjx Date: Wed, 20 Apr 2022 21:11:09 +0800 Subject: [PATCH] fixed the issue of rendering url valid when it contains white spaces at its begining --- lib/Controller/MainController.php | 1 + lib/Tools/Helper.php | 8 ++++---- lib/Tools/Youtube.php | 4 ++-- src/App.vue | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/Controller/MainController.php b/lib/Controller/MainController.php index 572447d..d17331e 100644 --- a/lib/Controller/MainController.php +++ b/lib/Controller/MainController.php @@ -15,6 +15,7 @@ use OCP\AppFramework\Http\TemplateResponse; use OCP\IL10N; use OCP\IRequest; use OC_Util; +use OC\Files\Filesystem; class MainController extends Controller { diff --git a/lib/Tools/Helper.php b/lib/Tools/Helper.php index fd6641a..eec2b2f 100644 --- a/lib/Tools/Helper.php +++ b/lib/Tools/Helper.php @@ -10,7 +10,7 @@ class Helper { public const DOWNLOADTYPE = ['ARIA2' => 1, 'YOUTUBE-DL' => 2, 'OTHERS' => 3]; public const STATUS = ['ACTIVE' => 1, 'PAUSED' => 2, 'COMPLETE' => 3, 'WAITING' => 4, 'ERROR' => 5]; - const MAXLEN = 255; + const MAXFILELEN = 255; public static function isUrl($URL) { @@ -61,8 +61,8 @@ class Helper } public static function clipFilename($filename) { - if (($len = strlen($filename)) > 64) { - return substr($filename, $len - 64); + if (($len = strlen($filename)) > self::MAXFILELEN) { + return substr($filename, $len - self::MAXFILELEN); } return $filename; } @@ -73,7 +73,7 @@ class Helper } else { $filename = self::getUrlPath($url); } - return substr($filename, 0, self::MAXLEN); + return substr($filename, 0, self::MAXFILELEN); } public static function formatBytes($size, $precision = 2) { diff --git a/lib/Tools/Youtube.php b/lib/Tools/Youtube.php index 0623d58..0573dfd 100644 --- a/lib/Tools/Youtube.php +++ b/lib/Tools/Youtube.php @@ -104,9 +104,9 @@ class Youtube return $this; } - public static function create() + public static function create($options) { - return new self(); + return new self($options); } public function setDownloadDir($dir) diff --git a/src/App.vue b/src/App.vue index 2f54172..098d5e7 100644 --- a/src/App.vue +++ b/src/App.vue @@ -56,7 +56,7 @@ export default { let element = event.target; let formWrapper = element.closest("form"); let formData = helper.getData(formWrapper); - let inputValue = formData["text-input-value"]; + let inputValue = formData["text-input-value"].trim(); let message; if (formData.type === "youtube-dl") { formData["audio-only"] = "";