Skip to content

Commit c3ab88b

Browse files
committed
Update Resource.php
1 parent 1884c1b commit c3ab88b

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/ScriptCompiler/Resource.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,25 @@ class Resource {
1717

1818
public function __construct($data) {
1919
$this->url = $data["url"];
20-
$this->isRemote = (boolean) parse_url($this->url, PHP_URL_HOST);
20+
21+
$prependScheme = preg_match("/^\/\//", $this->url);
22+
$this->isRemote = $prependScheme || parse_url($this->url, PHP_URL_HOST);
23+
if ($prependScheme) {
24+
$this->url = (empty($_SERVER["HTTPS"]) ? "http:" : "https:") . $this->url;
25+
}
2126

2227
if (isset($data["minified"])) {
2328
$this->minified = $data["minified"];
2429
}
2530

2631
if (isset($data["language"])) {
27-
$this->language = $data["minified"];
32+
$this->language = $data["language"];
2833
} else {
29-
$this->language = pathinfo($this->url, PATHINFO_EXTENSION);
34+
if ($this->isRemote) {
35+
$this->language = pathinfo(parse_url($this->url, PHP_URL_PATH), PATHINFO_EXTENSION);
36+
} else {
37+
$this->language = pathinfo($this->url, PATHINFO_EXTENSION);
38+
}
3039
}
3140
}
3241

0 commit comments

Comments
 (0)