diff options
Diffstat (limited to 'application/api/ApiUtils.php')
-rw-r--r-- | application/api/ApiUtils.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/application/api/ApiUtils.php b/application/api/ApiUtils.php index 5156a5f7..eb1ca9bc 100644 --- a/application/api/ApiUtils.php +++ b/application/api/ApiUtils.php | |||
@@ -67,7 +67,7 @@ class ApiUtils | |||
67 | if (! $bookmark->isNote()) { | 67 | if (! $bookmark->isNote()) { |
68 | $out['url'] = $bookmark->getUrl(); | 68 | $out['url'] = $bookmark->getUrl(); |
69 | } else { | 69 | } else { |
70 | $out['url'] = $indexUrl . $bookmark->getUrl(); | 70 | $out['url'] = rtrim($indexUrl, '/') . '/' . ltrim($bookmark->getUrl(), '/'); |
71 | } | 71 | } |
72 | $out['shorturl'] = $bookmark->getShortUrl(); | 72 | $out['shorturl'] = $bookmark->getShortUrl(); |
73 | $out['title'] = $bookmark->getTitle(); | 73 | $out['title'] = $bookmark->getTitle(); |
@@ -89,12 +89,12 @@ class ApiUtils | |||
89 | * If no URL is provided, it will generate a local note URL. | 89 | * If no URL is provided, it will generate a local note URL. |
90 | * If no title is provided, it will use the URL as title. | 90 | * If no title is provided, it will use the URL as title. |
91 | * | 91 | * |
92 | * @param array $input Request Link. | 92 | * @param array|null $input Request Link. |
93 | * @param bool $defaultPrivate Request Link. | 93 | * @param bool $defaultPrivate Setting defined if a bookmark is private by default. |
94 | * | 94 | * |
95 | * @return Bookmark instance. | 95 | * @return Bookmark instance. |
96 | */ | 96 | */ |
97 | public static function buildLinkFromRequest($input, $defaultPrivate) | 97 | public static function buildBookmarkFromRequest(?array $input, bool $defaultPrivate): Bookmark |
98 | { | 98 | { |
99 | $bookmark = new Bookmark(); | 99 | $bookmark = new Bookmark(); |
100 | $url = ! empty($input['url']) ? cleanup_url($input['url']) : ''; | 100 | $url = ! empty($input['url']) ? cleanup_url($input['url']) : ''; |
@@ -110,6 +110,15 @@ class ApiUtils | |||
110 | $bookmark->setTags(! empty($input['tags']) ? $input['tags'] : []); | 110 | $bookmark->setTags(! empty($input['tags']) ? $input['tags'] : []); |
111 | $bookmark->setPrivate($private); | 111 | $bookmark->setPrivate($private); |
112 | 112 | ||
113 | $created = \DateTime::createFromFormat(\DateTime::ATOM, $input['created'] ?? ''); | ||
114 | if ($created instanceof \DateTimeInterface) { | ||
115 | $bookmark->setCreated($created); | ||
116 | } | ||
117 | $updated = \DateTime::createFromFormat(\DateTime::ATOM, $input['updated'] ?? ''); | ||
118 | if ($updated instanceof \DateTimeInterface) { | ||
119 | $bookmark->setUpdated($updated); | ||
120 | } | ||
121 | |||
113 | return $bookmark; | 122 | return $bookmark; |
114 | } | 123 | } |
115 | 124 | ||