{"id":15755419,"url":"https://github.com/grantbirki/github-username-regex-js","last_synced_at":"2026-01-08T12:32:03.400Z","repository":{"id":210342739,"uuid":"726232521","full_name":"GrantBirki/github-username-regex-js","owner":"GrantBirki","description":"A regular expression that only matches a currently valid Github username or GitHub EMU handle","archived":false,"fork":false,"pushed_at":"2024-09-23T22:25:55.000Z","size":132,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-09T14:18:53.495Z","etag":null,"topics":["github","nodejs","regex","validation"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/github-username-regex-js","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GrantBirki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-12-01T20:29:56.000Z","updated_at":"2023-12-02T06:07:26.000Z","dependencies_parsed_at":"2023-12-02T06:23:42.022Z","dependency_job_id":"dc6422e7-077b-4f6f-945e-d20f3fbc9453","html_url":"https://github.com/GrantBirki/github-username-regex-js","commit_stats":{"total_commits":24,"total_committers":2,"mean_commits":12.0,"dds":0.08333333333333337,"last_synced_commit":"d7c6efe30a9e870b9b5282baf64e4d4ec12d9aa4"},"previous_names":["grantbirki/github-username-regex-js","grantbirki/github-username-regex"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrantBirki%2Fgithub-username-regex-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrantBirki%2Fgithub-username-regex-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrantBirki%2Fgithub-username-regex-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrantBirki%2Fgithub-username-regex-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GrantBirki","download_url":"https://codeload.github.com/GrantBirki/github-username-regex-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229517343,"owners_count":18085481,"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":["github","nodejs","regex","validation"],"created_at":"2024-10-04T08:21:46.088Z","updated_at":"2026-01-08T12:32:03.353Z","avatar_url":"https://github.com/GrantBirki.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# github-username-regex-js ✅\n\n[![npm version](https://img.shields.io/npm/v/github-username-regex-js.svg)](https://www.npmjs.com/package/github-username-regex-js) [![lint](https://github.com/GrantBirki/github-username-regex-js/actions/workflows/lint.yml/badge.svg)](https://github.com/GrantBirki/github-username-regex-js/actions/workflows/lint.yml) [![test](https://github.com/GrantBirki/github-username-regex-js/actions/workflows/test.yml/badge.svg)](https://github.com/GrantBirki/github-username-regex-js/actions/workflows/test.yml) [![build](https://github.com/GrantBirki/github-username-regex-js/actions/workflows/build.yml/badge.svg)](https://github.com/GrantBirki/github-username-regex-js/actions/workflows/build.yml)\n\nA regular expression that only matches a valid [GitHub](https://github.com/) username or [GitHub EMU](https://docs.github.com/en/enterprise-cloud@latest/admin/identity-and-access-management/understanding-iam-for-enterprises/about-enterprise-managed-users) username.\n\n```javascript\nimport githubUsernameRegex from 'github-username-regex-js';\n\ngithubUsernameRegex.test('monalisa'); //=\u003e true\ngithubUsernameRegex.test('mona-lisa'); //=\u003e true\ngithubUsernameRegex.test('name_company'); //=\u003e true - GitHub EMU\ngithubUsernameRegex.test('mona-lisa-'); //=\u003e false\ngithubUsernameRegex.test('mona%$^lisa'); //=\u003e false\n```\n\nAccording to the form validation messages on the [*Join GitHub*](https://github.com/join) page,\n\n- GitHub usernames may only contain alphanumeric characters or hyphens\n- GitHub usernames cannot have multiple consecutive hyphens\n- GitHub usernames cannot begin or end with a hyphen\n- Usernames can have a maximum of 39 characters\n\nAdditionally, this package (regex) also checks for GitHub EMU handles to see if they are valid as well. GitHub EMUs can look like this:\n\n- `name_company`\n- `name-with-hyphens_company`\n- `name-with-numbers123_company123`\n- etc\n\n## Installation\n\nYou can install [this package](https://www.npmjs.com/package/github-username-regex-js) via [npm](https://www.npmjs.com/):\n\n```bash\nnpm install github-username-regex-js\n```\n\n## Usage\n\n```javascript\n// Import the package\nimport githubUsernameRegex from 'github-username-regex-js';\n\n// Returns `true`\ngithubUsernameRegex.test('a');\ngithubUsernameRegex.test('0');\ngithubUsernameRegex.test('a-b');\ngithubUsernameRegex.test('a-b-123');\ngithubUsernameRegex.test('a'.repeat(39));\ngithubUsernameRegex.test('some-person_githubEmuCompany'); // GitHub EMU\n\n// Returns `false`\ngithubUsernameRegex.test('');\ngithubUsernameRegex.test('a_b');\ngithubUsernameRegex.test('a--b');\ngithubUsernameRegex.test('a-b-');\ngithubUsernameRegex.test('-a-b');\ngithubUsernameRegex.test('a'.repeat(40));\n```\n\n\u003e [!NOTE]\n\u003e This module doesn't take reserved usernames into consideration. For example, it matches `help`, `about` and `pricing` even though they are reserved words and cannot be used as GitHub usernames.\n\n## License\n\n[Creative Commons Zero v1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/deed)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrantbirki%2Fgithub-username-regex-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrantbirki%2Fgithub-username-regex-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrantbirki%2Fgithub-username-regex-js/lists"}