Skip to content

Instantly share code, notes, and snippets.

@ccwq
Last active December 7, 2016 08:55
Show Gist options
  • Save ccwq/dea1c5f93584483850759808430c2897 to your computer and use it in GitHub Desktop.
Save ccwq/dea1c5f93584483850759808430c2897 to your computer and use it in GitHub Desktop.
/**
* 获取当前页面的目录
* "http://aa/b/s/b.html" //"http://aa/b/s/"
* "http://aa/b/s/b.html/#a/b/c" //"http://aa/b/s/"
* "http://aa/b/s/b.html/?asdf=p&a=s#a/b/c" //"http://aa/b/s/"
**/
location.href.replace(/([^#?]+)\/.*?$/,"$1/")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment