Skip to content

Instantly share code, notes, and snippets.

@tyom
Created May 8, 2019 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyom/2cd85166375763e15c855b617111c327 to your computer and use it in GitHub Desktop.
Save tyom/2cd85166375763e15c855b617111c327 to your computer and use it in GitHub Desktop.
This is technique is useful when dealing with static subdirectories. Unless the current directory has trailing slash it won't be regarded it as such, leading to wrong relative path.
window.location.href.match(/[^/]$/) && (window.location.href += '/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment