Skip to content

Commit

Permalink
Input can be an empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
kvz committed Nov 26, 2024
1 parent 759421a commit 52d25b5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/transloadit/Transloadit.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ public function signedSmartCDNUrl(
if (!$templateSlug) {
throw new \InvalidArgumentException('template is required');
}
if ($inputField === null) {
throw new \InvalidArgumentException('input must be a string');
}

// Add auth parameters
$queryParams = [];
Expand Down
23 changes: 23 additions & 0 deletions test/SmartCDNNodeParityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,27 @@ public function testEmptyInputField(): void {

$this->assertEquals($nodeUrl, $url, 'Unset input field should be handled the same as node');
}

public function testEmptyStringInput(): void {
$params = [
'workspace' => $this->workspace,
'template' => $this->template,
'input' => '',
'expire_at_ms' => $this->expireAt,
'url_params' => [
'width' => '100'
]
];

$url = $this->transloadit->signedSmartCDNUrl(
$params['workspace'],
$params['template'],
$params['input'],
$params['url_params'],
['expireAtMs' => $params['expire_at_ms']]
);
$nodeUrl = $this->runNodeScript($params);

$this->assertEquals($nodeUrl, $url, 'Empty string input should be handled the same as node');
}
}
3 changes: 2 additions & 1 deletion tool/node-smartcdn-sig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ function signSmartCDNUrl(params: SmartCDNParams): string {

if (!workspace) throw new Error('workspace is required')
if (!template) throw new Error('template is required')
if (!input) throw new Error('input is required')
if (input === null || input === undefined)
throw new Error('input must be a string')
if (!auth_key) throw new Error('auth_key is required')
if (!auth_secret) throw new Error('auth_secret is required')

Expand Down

0 comments on commit 52d25b5

Please sign in to comment.