diff options
author | Teddy Wing | 2020-03-22 15:43:24 +0100 |
---|---|---|
committer | Teddy Wing | 2020-03-22 15:43:24 +0100 |
commit | aeb7a52f9252c8295d43c50927bd74a8e4567877 (patch) | |
tree | 7bc3948e1cb32ce4edd553eb6af145fd5d064143 | |
parent | 5a07b8d04d216653695410aee8d03d2a990e8464 (diff) | |
download | godoc-links-aeb7a52f9252c8295d43c50927bd74a8e4567877.tar.bz2 |
github.com: Add a function to get the Go package name from the URL
-rw-r--r-- | godoc-links.user.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/godoc-links.user.js b/godoc-links.user.js index 8b7c17a..ccdaee7 100644 --- a/godoc-links.user.js +++ b/godoc-links.user.js @@ -35,3 +35,15 @@ function github_add_godoc_link () { link_el.href = ''; link_el.textContent = '(GoDoc)'; } + + +// Turns: +// +// https://github.com/google/uuid/blob/master/go.mod +// +// into: +// +// github.com/google/uuid +function github_package_name () { + return window.location.href.split('/').slice(2, 5).join('/'); +} |