1function setPostSection() { 2 3 /* let allTagList = allTags.toLowerCase().replaceAll(/&.+?;/g, '') 4 allTagList = allTagList.split(", ") 5 console.log(allTagList) */ 6 const ogTypeMeta = document.querySelector('meta[property="og:type"]'); 7 8 if (ogTypeMeta && ogTypeMeta.getAttribute('content') === 'article') { 9 const ogTagMeta = document.querySelectorAll('meta[property="article:tag"]'); 10 const articleTags = [...ogTagMeta].map(element => { 11 return element.getAttribute('content') 12 .toLowerCase() // Convert to lowercase 13 .replace(/& amp;/g, '') 14 .replace(/&/g, '') 15 .replace(/\s+/g, '-') 16 .replace(/[^\w-]+/g, '') 17 }); 18 let referrerSection = articleTags[0]; 19 20 21 // Get the referrer URL. 22 const referrerUrl = document.referrer; 23 24 // Get the current domain. 25 const currentDomain = window.location.hostname; 26 if (referrerUrl) { 27 // Check if a referrer URL exists and if its hostname matches the current domain. 28 try { 29 const referrerHostname = new URL(referrerUrl).hostname; 30 console.log(referrerHostname) 31 32 if (referrerHostname === currentDomain) { 33 let parts = referrerUrl.split('/'); 34 let lastParts = parts[parts.length - 2]; 35 lastParts = lastParts.replace(/\-multi/g, '') 36 const referrerPartisTag = lastParts === 'home-care'|'aged-care'| 'community-living' ? true : articleTags.some(tag => tag === lastParts); 37 38 if (referrerPartisTag) { 39 referrerSection = lastParts 40 41 } 42 } 43 44 45 46 } catch (error) { 47 // This catches cases where the referrerUrl is malformed or empty, 48 // such as when navigating directly or from a local file. 49 console.log(error); 50 } 51 } 52 const newMetaTag = document.createElement('meta'); 53 newMetaTag.setAttribute('name', 'section-tag'); 54 newMetaTag.setAttribute('content', referrerSection); 55 document.head.appendChild(newMetaTag) 56 } 57};
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.