Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argument 2 passed to Orchestra\Asset\Asset::style() must be of the type string #111

Open
leenooks opened this issue Jun 2, 2019 · 4 comments

Comments

@leenooks
Copy link

leenooks commented Jun 2, 2019

Hi, if you use @css or @js with a url without http(s), it results in the above error. EG:
@css('//cdn/file') or @js('//cdn/file')

A fix I propose for this is to modify Theme.php, and in the function url(), add the following to the beginning of the function:

    public function url($url)
    {
        // return external URLs unmodified
        if (preg_match('#^//#',$url))
                return $url;

        $url = ltrim($url, '/');
...
@igaster
Copy link
Owner

igaster commented Jul 3, 2019

Fixed!

@igaster igaster closed this as completed Jul 3, 2019
@leenooks
Copy link
Author

leenooks commented Jul 17, 2019

BTW: I needed to apply the same fix to the url() function in src/Themes.php

IE:

 // Return url of current theme
    public function url($filename)
    {
         if (preg_match('/^((http(s?):)?\/\/)/i', $filename)) {
            return $filename;
         }
 ...

@igaster
Copy link
Owner

igaster commented Oct 11, 2019

@leenooks why is this broken?

this line: https://github.com/igaster/laravel-theme/blob/master/src/Themes.php#L319

will call the Theme::url() which should return the correct value. Unless you didn't set some active theme. Is that your case?

@igaster igaster reopened this Oct 11, 2019
@leenooks
Copy link
Author

Without my patch, when you have @js('https://my.javascript.url/to/a/jsfile') results it being rendered as a path, ie: <script src="https://my.web.url/https://my.javascript.url/to/a/jsfile"></script>

leenooks added a commit to leenooks/laravel-theme that referenced this issue Oct 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants