mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-28 23:03:25 +09:00
Hide category_srl from short URL on document read page
This commit is contained in:
parent
1e30de7ce5
commit
74d651afdd
1 changed files with 19 additions and 11 deletions
|
|
@ -1,20 +1,28 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* Remove comment_srl and unnecessary page number from short URL
|
||||
* Remove unnecessary parameters from short URL.
|
||||
*
|
||||
* - category
|
||||
* - comment_srl
|
||||
* - page number
|
||||
*/
|
||||
(function() {
|
||||
var newpath = '';
|
||||
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);
|
||||
}
|
||||
newpath = location.pathname.replace(/\/(comment|page)\/([0-9]+)$/, '');
|
||||
}
|
||||
if (location.pathname.match(/\/([0-9]+)$/) && location.search.match(/^\?category=[0-9]+$/)) {
|
||||
newpath = newpath ? newpath : location.pathname;
|
||||
}
|
||||
if (newpath && location.hash && location.hash != '#') {
|
||||
newpath += location.hash;
|
||||
}
|
||||
if (newpath && history.replaceState) {
|
||||
history.replaceState({
|
||||
rx_replaced: true,
|
||||
prev: location.pathname,
|
||||
}, '', newpath);
|
||||
}
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue