Skip to content

bug: invalid asset url when mutation is empty and auto mode is on #9

@martinadamik

Description

@martinadamik

https://github.com/filejet/filejet-bundle/blob/master/src/Twig/FileJetExtension.php#L40

public function getAsset(string $path, string $mutation = null): string
    {
        $mutation = empty($mutation) ? '' : "/${mutation}";
        $mutation .= $this->config->isAutoMode() ? ',auto' : '';
        $originPath = urlencode("{$this->config->getBaseUrl()}{$path}");

        return "{$this->config->getPublicUrl()}/ext{$mutation}?src={$originPath}";
    }

should looks like e.g

public function getAsset(string $path, string $mutation = null): string
    {
        $parts = [];

        if($mutation) {
            $parts[] = $mutation;
        }

        if($this->config->isAutoMode()) {
            $parts[] = 'auto';
        }

        $finalMutation = !empty($parts) ? "/" . implode(',', $parts) : '';
        $originPath = urlencode("{$this->config->getBaseUrl()}{$path}");

        return "{$this->config->getPublicUrl()}/ext{$finalMutation}?src={$originPath}";
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions