Skip to content

Commit

Permalink
revert to broken prev code to investigate bug a bit more
Browse files Browse the repository at this point in the history
  • Loading branch information
progapandist committed Jun 9, 2024
1 parent a1c4a71 commit f2f8265
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/javascript/controllers/random_image_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ export default class extends Controller {

// Update the page URL with the current slug value while keeping all query parameters
const currentSlug = this.slugValue;
console.log("slug value ", currentSlug);

const currentPath = `/works/${currentSlug}${window.location.pathname}`;
console.log("currentPath", currentPath);
const currentPath = window.location.pathname.replace(
/\/works\/\w+/,
`/works/${currentSlug}`
);
const currentURL = `${currentPath}${window.location.search}${window.location.hash}`;
window.history.replaceState({}, "", currentURL);

const newURL = `${currentPath}${window.location.search}${window.location.hash}`;
window.history.replaceState({}, "", newURL);
// Add event listener to intercept clicks on the viewport
document.addEventListener("click", this.handleClick.bind(this));
}

handleClick(event) {
Expand Down

0 comments on commit f2f8265

Please sign in to comment.