修改功能,现已测试注册登录忘记密码
This commit is contained in:
@@ -36,6 +36,48 @@ const CommonUtil = {
|
||||
return /^(localhost|127\.0\.0\.1|0\.0\.0\.0)$/i.test(window.location.hostname);
|
||||
},
|
||||
|
||||
safeHref(url) {
|
||||
if (!url) return '#';
|
||||
const value = String(url).trim();
|
||||
const lowered = value.toLowerCase();
|
||||
if (lowered.startsWith('javascript:') || lowered.startsWith('data:') || lowered.startsWith('vbscript:')) {
|
||||
return '#';
|
||||
}
|
||||
return value;
|
||||
},
|
||||
|
||||
siteHref(url) {
|
||||
const value = this.safeHref(url);
|
||||
if (!value || value === '#') return value;
|
||||
if (/^(?:https?:)?\/\//i.test(value) || value.startsWith('javascript:')) return value;
|
||||
if (!value.startsWith('/')) return value;
|
||||
if (!this.isLocalHtmlPathMode()) return value;
|
||||
if (value.startsWith('/html/')) return value;
|
||||
|
||||
const freeArticleMatch = value.match(/^\/mianfei\/([^/?#]+)\.html([?#].*)?$/i);
|
||||
if (freeArticleMatch) {
|
||||
return `/html/mianfei.html?id=${encodeURIComponent(decodeURIComponent(freeArticleMatch[1]))}${freeArticleMatch[2] || ''}`;
|
||||
}
|
||||
|
||||
if (/^\/[^/?#]+\.html(?:[?#].*)?$/i.test(value)) return `/html${value}`;
|
||||
return value;
|
||||
},
|
||||
|
||||
isLocalHtmlPathMode() {
|
||||
const hostname = window.location && window.location.hostname;
|
||||
return hostname === 'localhost' || hostname === '127.0.0.1' || Boolean(window.location && window.location.port);
|
||||
},
|
||||
|
||||
rewritePageRootLinks() {
|
||||
const $ = this.$;
|
||||
$('a[href^="/"]').each((index, link) => {
|
||||
const $link = $(link);
|
||||
const href = $link.attr('href');
|
||||
const nextHref = this.siteHref(href);
|
||||
if (href !== nextHref) $link.attr('href', nextHref);
|
||||
});
|
||||
},
|
||||
|
||||
freeArticleHref(articleId) {
|
||||
const id = encodeURIComponent(articleId || '');
|
||||
if (!id) return 'javascript:void(0)';
|
||||
|
||||
Reference in New Issue
Block a user