1(function ($) { 2 3 if(window.location.href.indexOf('?') !== -1) { 4 5 $(document).ready(function () { 6 $('a').on('click', function (e) { 7 var attach_param = true; 8 var parameter_tags = window.location.search; 9 var current_path = window.location.pathname; 10 var destination_path = null; 11 12 if (this.getAttribute('href').charAt(0) != "#") { 13 destination_path = new URL(this.href, window.location.origin).pathname; 14 } 15 16 // check for exception classes 17 const class_exceptions = [ 18 "cboxElement" 19 ]; 20 var class_list = $(this).attr('class'); 21 if(class_list != null) { 22 var class_list_array = class_list.split(/\s+/); 23 for(var i=0;i < class_exceptions.length;i++) { 24 if(class_list_array.includes(class_exceptions[i])) { 25 attach_param = false; 26 } 27 } 28 } 29 30 // Only preserve query params within the Story Hub / Newsroom 31 // search experience. Other site links should stay clean. 32 const allowed_paths = [ 33 "/pressroom/news-releases", 34 "/newsroom/search-stories", 35 "/newsroom/search-news", 36 "/newsroom/search", 37 "/story-hub/search-science", 38 "/story-hub/search-stories", 39 "/story-hub/search-news", 40 "/story-hub/search", 41 "/story-hub/media-resources" 42 ]; 43 const reset_paths = [ 44 "/newsroom/search-stories", 45 "/newsroom/search-news", 46 "/story-hub/search-science", 47 "/story-hub/search-stories", 48 "/story-hub/search-news", 49 "/story-hub/media-resources" 50 ]; 51 52 if (!allowed_paths.includes(current_path)) { 53 attach_param = false; 54 } 55 56 if (!destination_path || !allowed_paths.includes(destination_path)) { 57 attach_param = false; 58 } 59 60 if (destination_path && reset_paths.includes(destination_path)) { 61 attach_param = false; 62 } 63 64 // if not an exception class, continue with reattaching param 65 if(attach_param) { 66 // check for anchor tag 67 if(this.getAttribute('href').charAt(0) != "#") { 68 e.preventDefault(); 69 70 var destination = new URL(this.href, window.location.origin); 71 var current_params = new URLSearchParams(parameter_tags); 72 73 current_params.forEach(function (value, key) { 74 // Keep explicit link params, only carry over missing query params 75 // from the current page. 76 if (!destination.searchParams.has(key)) { 77 destination.searchParams.append(key, value); 78 } 79 }); 80 81 location.href = destination.toString(); 82 } else { 83 location.href = this.href; 84 } 85 } 86 }); 87 }); 88 } 89}(jQuery));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.