Fix #1294 use history.replaceState() to remove unnecessary comment_srl and page number from URL if new rewrite rules are in effect

This commit is contained in:
Kijin Sung 2020-10-30 22:33:18 +09:00
parent dff97a9604
commit 6c19e6ebff

View file

@ -132,7 +132,24 @@ function doScrap(document_srl)
jQuery.exec_json('member.procMemberScrapDocument', params);
}
jQuery(function($){
/* remove comment_srl and unnecessary page number from short URL */
var match = location.pathname.match(/\/([a-zA-Z0-9_]+)\/([0-9]+)\/(comment|page)\/([0-9]+)$/);
if (match && match[1] === window.current_mid) {
var newpath = location.pathname.replace(/\/(comment|page)\/([0-9]+)$/, '');
if (location.hash && location.hash !== '#') {
newpath += location.hash;
}
if (history.replaceState) {
history.replaceState({
rx_replaced: true,
prev: location.pathname,
}, '', newpath);
}
}
$(document.body).click(function(e){
var t = $(e.target), act, params = {};