mailto: 등 URN 링크 문제 고침 by @bnu

xpressengine/xe-core#2174
This commit is contained in:
Kijin Sung 2017-11-30 22:11:55 +09:00
parent a199333a2e
commit 999bc92753

View file

@ -86,6 +86,7 @@
URITemplate : window.URITemplate,
SecondLevelDomains : window.SecondLevelDomains,
IPv6 : window.IPv6,
baseurl : null,
/**
* @brief 특정 name을 가진 체크박스들의 checked 속성 변경
@ -198,6 +199,9 @@
/* 동일 사이트 내 주소인지 판단 (프로토콜 제외) */
isSameHost: function(url) {
if (typeof url !== "string") {
return false;
}
if (url.match(/^\/[^\/]/)) {
return true;
}
@ -205,16 +209,21 @@
return false;
}
var site_baseurl = window.XE.URI(window.request_uri).normalizePort().normalizePathname();
site_baseurl = site_baseurl.hostname() + site_baseurl.directory();
if (!window.XE.baseurl) {
window.XE.baseurl = window.XE.URI(window.request_uri).normalizePort().normalizePathname();
window.XE.baseurl = window.XE.baseurl.hostname() + window.XE.baseurl.directory();
}
var target_url = window.XE.URI(url).normalizePort().normalizePathname();
if (target_url.is("urn")) {
return false;
}
if (!target_url.hostname()) {
target_url = target_url.absoluteTo(window.request_uri);
}
target_url = target_url.hostname() + target_url.directory();
return target_url.indexOf(site_baseurl) === 0;
return target_url.indexOf(window.XE.baseurl) === 0;
}
};
@ -233,8 +242,8 @@ jQuery(function($) {
/* Tabnapping protection, step 1 */
$('a[target]').each(function() {
var $this = $(this);
var href = $this.attr('href');
var target = $this.attr('target');
var href = $this.attr('href').trim();
var target = $this.attr('target').trim();
if (!href || !target || target === '_top' || target === '_self' || target === '_parent') {
return;
}
@ -250,8 +259,8 @@ jQuery(function($) {
/* Tabnapping protection, step 2 */
$('body').on('click', 'a[target]', function(event) {
var $this = $(this);
var href = $this.attr('href');
var target = $this.attr('target');
var href = $this.attr('href').trim();
var target = $this.attr('target').trim();
if (!href || !target || target === '_top' || target === '_self' || target === '_parent') {
return;
}