Skip to content

Commit e8bc5a8

Browse files
author
p01
committed
moved sameOrigin method to cls.ResourceUtil
1 parent 004bea3 commit e8bc5a8

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/resource-manager/resource_service.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -406,15 +406,7 @@ cls.ResourceContext = function(data)
406406

407407
// sameOrigin check
408408
// TODO: sameOrigin check for iframes
409-
res.sameOrigin = false;
410-
if (frame.resource != null && frame.resource.protocol == res.protocol &&
411-
(
412-
frame.resource.host == res.host
413-
|| frame.resource.host.match(new RegExp('\\.' + res.host + '$')) != null
414-
)
415-
)
416-
res.sameOrigin = true;
417-
409+
res.sameOrigin = cls.ResourceUtil.sameOrigin(frame.resource, res);
418410
}
419411
else
420412
{

src/resource-manager/resource_util.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,3 +434,16 @@ cls.ResourceUtil.http_status_codes = {
434434
501: 'Not Implemented', 502: 'Bad Gateway', 503: 'Service Unavailable',
435435
504: 'Gateway Timeout', 505: 'HTTP Version Not Supported'
436436
}
437+
438+
cls.ResourceUtil.sameOrigin = function(reference, url)
439+
{
440+
if (reference.protocol == url.protocol)
441+
{
442+
if (reference.host == url.host)
443+
return true;
444+
if (reference.host.match(new RegExp('\\.' + url.host + '$')) != null)
445+
return true;
446+
}
447+
448+
return false;
449+
}

0 commit comments

Comments
 (0)