diff options
author | Dylan William Hardison <dylan@hardison.net> | 2018-06-15 02:50:08 +0200 |
---|---|---|
committer | Kohei Yoshino <kohei.yoshino@gmail.com> | 2018-06-15 02:50:08 +0200 |
commit | 404dc5496967203c5f99755340f43d712420446a (patch) | |
tree | b369a872bb1fa58c0ad95e249347dc5f8905e337 /extensions/BugModal/web | |
parent | 69e02e0576fc834de982ab6fa3d5b77ce7fe472a (diff) | |
download | bugzilla-404dc5496967203c5f99755340f43d712420446a.tar.gz bugzilla-404dc5496967203c5f99755340f43d712420446a.tar.xz |
Bug 1468848 - Change presentation of show_bug.cgi urls to be /bug/ID or /bug/ALIAS.
Diffstat (limited to 'extensions/BugModal/web')
-rw-r--r-- | extensions/BugModal/web/bug_modal.js | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/extensions/BugModal/web/bug_modal.js b/extensions/BugModal/web/bug_modal.js index bf5c300e1..9d2701e51 100644 --- a/extensions/BugModal/web/bug_modal.js +++ b/extensions/BugModal/web/bug_modal.js @@ -1344,15 +1344,19 @@ function confirmUnsafeURL(url) { // fix url after bug creation/update if (history && history.replaceState) { - var href = document.location.href; - if (!href.match(/show_bug\.cgi/)) { - history.replaceState(null, BUGZILLA.bug_title, 'show_bug.cgi?id=' + BUGZILLA.bug_id); + let bug_id = BUGZILLA.bug_id; + let bug_alias = BUGZILLA.bug_alias; + let bug_slug = bug_alias || bug_id; + let url = new URL(document.location.href); + if (!url.pathname.match(/^bug\/[0-9]+/)) { + url.searchParams.delete("id"); + let new_url = url.search ? `/bug/${bug_slug}${url.search}` : `/bug/${bug_slug}`; + if (url.hash) { + new_url += url.hash; + } + history.replaceState(null, BUGZILLA.bug_title, new_url); document.title = BUGZILLA.bug_title; } - if (href.match(/show_bug\.cgi\?.*list_id=/)) { - href = href.replace(/[\?&]+list_id=(\d+|cookie)/, ''); - history.replaceState(null, BUGZILLA.bug_title, href); - } } // ajax wrapper, to simplify error handling and auth |