Skip to content
This repository was archived by the owner on Dec 31, 2022. It is now read-only.

Commit 36d9478

Browse files
committed
LABjs.next: inlining same_domain() since only used once, and also simplifying the logic of it, since only used on already canonical URLs
1 parent 689cc25 commit 36d9478

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

next/LAB.src.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@
5353
// test for array
5454
function is_array(arr) { return Object.prototype.toString.call(arr) == "[object Array]"; }
5555

56-
// test if script URL is on same domain as page or not
57-
function same_domain(src) { return (canonical_uri(src,root_domain).indexOf(root_domain) == 0); }
58-
5956
// make script URL absolute/canonical
6057
function canonical_uri(src,base_path) {
6158
var protocol_relative_regex = /^\/\/[^\/]/, absolute_regex = /^\w+\:\/\//;
@@ -183,8 +180,8 @@
183180
script.src = src;
184181
append_to.insertBefore(script,append_to.firstChild);
185182
}
186-
// same-domain, so use XHR+script injection
187-
else if (same_domain(src) && chain_opts[_UseLocalXHR]) {
183+
// same-domain and XHR allowed, so use XHR+script injection
184+
else if (src.indexOf(root_domain) == 0 && chain_opts[_UseLocalXHR]) {
188185
var xhr = XMLHttpRequest ? new XMLHttpRequest() : (ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : null);
189186
/*!START_DEBUG*/if (chain_opts[_Debug]) log_msg("start script preload (xhr): "+src);/*!END_DEBUG*/
190187
xhr.onreadystatechange = function() {

0 commit comments

Comments
 (0)