Skip to content

Commit 254bb0f

Browse files
committed
Fix ajax url pb with url prefix (http/s)
1 parent a67f6b2 commit 254bb0f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Ajax/common/traits/JsUtilsAjaxTrait.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,18 @@ protected function _getAjaxUrl($url, $attr) {
120120
if (JString::endswith($url, "/") === true) {
121121
$slash = "";
122122
}
123+
123124
if (JString::isNotNull($attr)) {
124125
if ($attr === "value") {
125126
$retour .= "url=url+'" . $slash . "'+$(this).val();\n";
126127
} elseif ($attr === "html") {
127128
$retour .= "url=url+'" . $slash . "'+$(this).html();\n";
128129
} elseif (\substr($attr, 0, 3) === "js:") {
129130
$retour .= "url=url+'" . $slash . "'+" . \substr($attr, 3) . ";\n";
130-
} elseif ($attr !== null && $attr !== "")
131-
$retour .= "url=url+'" . $slash . "'+($(this).attr('" . $attr . "')||'');\n";
131+
} elseif ($attr !== null && $attr !== "") {
132+
$retour .= "let elmUrl=$(this).attr('" . $attr . "')||'';";
133+
$retour .= "url=(!/^((http|https|ftp):\/\/)/.test(elmUrl))?url+'" . $slash . "'+elmUrl:elmUrl;\n";
134+
}
132135
}
133136
return $retour;
134137
}

0 commit comments

Comments
 (0)