
Product
Introducing Reports: An Extensible Reporting Framework for Socket Data
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.
shorten-repo-url
Advanced tools
Shorten GitHub links like GitHub shortens Issues and Commit links. Used on refined-github

Check out the demo page to see what each URL is shortened to. GitLab URLs are mostly compatible but they're not officially supported.
It works on any domain, so GitHub Enterprise is also supported.
$ npm install shorten-repo-url
const shortenRepoUrl = require('shorten-repo-url');
const HTML = shortenRepoUrl(
'https://github.com/nodejs/node/tree/v0.12/doc',
'https://github.com/nodejs/node' // same repo
);
//=> '<code>v0.12</code>' // repo-less URL
const HTML = shortenRepoUrl(
'https://github.com/nodejs/node/tree/v0.12/doc',
'https://github.com' // not the same repo
);
//=> 'nodejs/node@<code>v0.12</code>' // URL with repo
Returns the shortened URL in HTML as a string like nodejs/node@<code>v0.12</code>.
Type: string
The GitHub URL to shorten.
Type: string, like location.href
The URL of the current page, to build relative URLs like <code>v0.12</code> instead of the longer nodejs/node@<code>v0.12</code>
Automatically shorten the link's text if the text matches the URL, i.e. <a href="https://github.com">https://github.com</a>. If a data-original-href attribute is present, it will be used when comparing the link’s text and when generating the shortened URL.
Note: this function will never change the href of the link, it only changes the text.
It will return true or false depending on whether the link was shortened.
Type: Element
Example: shortenRepoUrl.applyToLink(document.querySelector(a))
Type: string, like location.href
Same as before.
MIT © Federico Brigante
FAQs
Shorten GitHub URLs like GitHub shortens Issues and Commit URLs
The npm package shorten-repo-url receives a total of 1,496 weekly downloads. As such, shorten-repo-url popularity was classified as popular.
We found that shorten-repo-url demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.