Skip to content

Commit

Permalink
fix double slash in requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala committed Jun 30, 2021
1 parent bc6539d commit 7762bd8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/FilePondField.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
class FilePondField extends AbstractUploadField
{
const BASE_CDN = "https://cdn.jsdelivr.net/gh/pqina";

/**
* @config
Expand Down Expand Up @@ -467,11 +468,12 @@ public function getExistingUploadsData()
*/
public static function Requirements()
{
$baseDir = "https://cdn.jsdelivr.net/gh/pqina/";
$baseDir = self::BASE_CDN;
if (!self::config()->use_cdn) {
$asset = ModuleResourceLoader::resourceURL('lekoala/silverstripe-filepond:javascript/FilePondField.js');
$baseDir = dirname($asset) . "/cdn";
}
$baseDir = rtrim($baseDir, '/');

// Polyfill to ensure max compatibility
if (self::config()->enable_polyfill) {
Expand Down
8 changes: 8 additions & 0 deletions tests/FilePondTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,12 @@ public function testCustomConfig()
$pond->addFilePondConfig('allowDrop', false);
$this->assertArrayHasKey('allowDrop', $pond->getFilePondConfig());
}

public function testRequirements()
{
FilePondField::config()->use_cdn = true;
FilePondField::Requirements();
FilePondField::config()->use_cdn = false;
FilePondField::Requirements();
}
}

0 comments on commit 7762bd8

Please sign in to comment.