MediaWiki:Common.js:修订间差异
| 第93行: | 第93行: | ||
} ); | } ); | ||
} ); | } ); | ||
//重定向 | |||
(function() { | |||
const url = new URL(window.location.href); | |||
const pathname = url.pathname; | |||
const searchParams = url.searchParams; | |||
const isIndexPhp = pathname === '/index.php'; | |||
const hasOnlyTitleParam = searchParams.size === 1 && searchParams.has('title'); | |||
const titleValue = searchParams.get('title') || ''; | |||
const hasValidTitle = titleValue.trim() !== ''; | |||
if (isIndexPhp && hasOnlyTitleParam && hasValidTitle) { | |||
const targetUrl = `/wiki/${encodeURIComponent(titleValue)}`; | |||
window.location.replace(targetUrl); | |||
} | |||
})(); | |||