{"id":13475356,"url":"https://github.com/refined-github/shorten-repo-url","last_synced_at":"2025-04-04T16:09:09.119Z","repository":{"id":38143289,"uuid":"95283126","full_name":"refined-github/shorten-repo-url","owner":"refined-github","description":"Shorten GitHub links like GitHub shortens Issues and Commit links.","archived":false,"fork":false,"pushed_at":"2024-11-08T01:54:14.000Z","size":102,"stargazers_count":83,"open_issues_count":0,"forks_count":15,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-28T15:04:37.318Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://npm.im/shorten-repo-url","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/refined-github.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"fregante","custom":["paypal.me/fregante","www.buymeacoffee.com/fregante"]}},"created_at":"2017-06-24T07:38:25.000Z","updated_at":"2025-01-24T09:56:37.000Z","dependencies_parsed_at":"2024-07-10T10:45:34.311Z","dependency_job_id":"a0b916cf-486d-4de1-9ff3-b06d93661f78","html_url":"https://github.com/refined-github/shorten-repo-url","commit_stats":{"total_commits":93,"total_committers":16,"mean_commits":5.8125,"dds":0.4408602150537635,"last_synced_commit":"e13393241d5d50c253747a7c2341cef021137fcd"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refined-github%2Fshorten-repo-url","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refined-github%2Fshorten-repo-url/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refined-github%2Fshorten-repo-url/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refined-github%2Fshorten-repo-url/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/refined-github","download_url":"https://codeload.github.com/refined-github/shorten-repo-url/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247208143,"owners_count":20901570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T16:01:19.707Z","updated_at":"2025-04-04T16:09:09.089Z","avatar_url":"https://github.com/refined-github.png","language":"JavaScript","funding_links":["https://github.com/sponsors/fregante","paypal.me/fregante","www.buymeacoffee.com/fregante"],"categories":["JavaScript"],"sub_categories":[],"readme":"# shorten-repo-url\n\n\u003e Shorten GitHub links like GitHub shortens Issues and Commit links. Used on [refined-github](https://github.com/refined-github/refined-github)\n\n![Demo](https://user-images.githubusercontent.com/1402241/27252232-8fdf8ed0-538b-11e7-8f19-12d317c9cd32.png)\n\nLook at [the tests](https://github.com/refined-github/shorten-repo-url/blob/main/index.test.js) to see what each URL is shortened to. GitLab URLs are mostly compatible but they're not officially supported.\n\nIt works on any domain, so GitHub Enterprise is also supported.\n\n## Install\n\n```\n$ npm install shorten-repo-url\n```\n\n## Usage\n\n```js\nconst shortenRepoUrl = require('shorten-repo-url');\n\nconst HTML = shortenRepoUrl(\n\t'https://github.com/nodejs/node/tree/v0.12/doc',\n\t'https://github.com/nodejs/node' // same repo\n);\n//=\u003e '\u003ccode\u003ev0.12\u003c/code\u003e' // repo-less URL\n\nconst HTML = shortenRepoUrl(\n\t'https://github.com/nodejs/node/tree/v0.12/doc',\n\t'https://github.com' // not the same repo\n);\n//=\u003e 'nodejs/node@\u003ccode\u003ev0.12\u003c/code\u003e' // URL with repo\n```\n\n## API\n\n### shortenRepoUrl(url, currentUrl)\n\nReturns the shortened URL in HTML as a `string` like `nodejs/node@\u003ccode\u003ev0.12\u003c/code\u003e`.\n\n#### url\n\nType: `string`\n\nThe GitHub URL to shorten.\n\n#### currentUrl\n\nType: `string`, like `location.href`\n\nThe URL of the current page, to build relative URLs like `\u003ccode\u003ev0.12\u003c/code\u003e` instead of the longer `nodejs/node@\u003ccode\u003ev0.12\u003c/code\u003e`\n\n### shortenRepoUrl.applyToLink(link, currentUrl)\n\nAutomatically shorten the link's text if the text matches the URL, i.e. `\u003ca href=\"https://github.com\"\u003ehttps://github.com\u003c/a\u003e`. If a `data-original-href` attribute is present, it will be used when comparing the link’s text and when generating the shortened URL.\n\nNote: this function will never change the `href` of the link, it only changes the text.\n\nIt will return `true` or `false` depending on whether the link was shortened.\n\n#### link\n\nType: `Element`\n\nExample: `shortenRepoUrl.applyToLink(document.querySelector(a))`\n\n#### currentUrl\n\nType: `string`, like `location.href`\n\nSame as before.\n\n## License\n\nMIT © [Federico Brigante](https://fregante.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frefined-github%2Fshorten-repo-url","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frefined-github%2Fshorten-repo-url","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frefined-github%2Fshorten-repo-url/lists"}