{"id":13394252,"url":"https://github.com/lukeed/navaid","last_synced_at":"2025-10-09T18:24:03.474Z","repository":{"id":32895623,"uuid":"138140611","full_name":"lukeed/navaid","owner":"lukeed","description":"A navigation aid (aka, router) for the browser in 850 bytes~!","archived":false,"fork":false,"pushed_at":"2024-01-20T17:33:27.000Z","size":93,"stargazers_count":796,"open_issues_count":6,"forks_count":26,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-09-18T04:58:48.541Z","etag":null,"topics":["browser","client-side","history","navigation","router"],"latest_commit_sha":null,"homepage":"","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/lukeed.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},"funding":{"github":"lukeed"}},"created_at":"2018-06-21T08:16:56.000Z","updated_at":"2025-08-27T13:22:19.000Z","dependencies_parsed_at":"2024-02-06T16:16:38.474Z","dependency_job_id":null,"html_url":"https://github.com/lukeed/navaid","commit_stats":{"total_commits":93,"total_committers":6,"mean_commits":15.5,"dds":"0.053763440860215006","last_synced_commit":"ff09dfdedecfd0e636bd13c53f7273b95c7bbbb2"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/lukeed/navaid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fnavaid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fnavaid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fnavaid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fnavaid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukeed","download_url":"https://codeload.github.com/lukeed/navaid/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fnavaid/sbom","scorecard":{"id":604501,"data":{"date":"2025-08-11","repo":{"name":"github.com/lukeed/navaid","commit":"ff09dfdedecfd0e636bd13c53f7273b95c7bbbb2"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.5,"checks":[{"name":"Code-Review","score":1,"reason":"Found 5/30 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/lukeed/navaid/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/lukeed/navaid/ci.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:20","Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:28","Warn: downloadThenRun not pinned by hash: .github/workflows/ci.yml:35","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 npmCommand dependencies pinned","Info:   0 out of   1 downloadThenRun dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: license:0","Info: FSF or OSI recognized license: MIT License: license:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 6 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T01:15:58.910Z","repository_id":32895623,"created_at":"2025-08-21T01:15:58.910Z","updated_at":"2025-08-21T01:15:58.910Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001940,"owners_count":26083226,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["browser","client-side","history","navigation","router"],"created_at":"2024-07-30T17:01:13.849Z","updated_at":"2025-10-09T18:24:03.455Z","avatar_url":"https://github.com/lukeed.png","language":"JavaScript","readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"navaid.png\" alt=\"navaid\" height=\"160\" /\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://npmjs.org/package/navaid\"\u003e\n    \u003cimg src=\"https://badgen.now.sh/npm/v/navaid\" alt=\"version\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/lukeed/navaid/actions\"\u003e\n    \u003cimg src=\"https://github.com/lukeed/navaid/workflows/CI/badge.svg\" alt=\"CI\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://licenses.dev/npm/navaid\"\u003e\n    \u003cimg src=\"https://licenses.dev/b/npm/navaid\" alt=\"licenses\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://npmjs.org/package/navaid\"\u003e\n    \u003cimg src=\"https://badgen.now.sh/npm/dm/navaid\" alt=\"downloads\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://packagephobia.now.sh/result?p=navaid\"\u003e\n    \u003cimg src=\"https://packagephobia.now.sh/badge?p=navaid\" alt=\"install size\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003eA navigation aid (aka, router) for the browser in 865 bytes~!\u003c/div\u003e\n\n## Install\n\n```\n$ npm install --save navaid\n```\n\n\n## Usage\n\n```js\nconst navaid = require('navaid');\n\n// Setup router\nlet router = navaid();\n// or: new Navaid();\n\n// Attach routes\nrouter\n  .on('/', () =\u003e {\n    console.log('~\u003e /');\n  })\n  .on('/users/:username', params =\u003e {\n    console.log('~\u003e /users/:username', params);\n  })\n  .on('/books/*', params =\u003e {\n    console.log('~\u003e /books/*', params);\n  });\n\n// Run as single instance\nrouter.run('/');\n//=\u003e \"~\u003e /\"\nrouter.run('/users/lukeed');\n//=\u003e \"~\u003e /users/:username { username: 'lukeed' }\"\nrouter.run('/books/kids/narnia');\n//=\u003e \"~\u003e /books/* { wild: 'kids/narnia' }\"\n\n// Run as long-lived router w/ history \u0026 \"\u003ca\u003e\" bindings\n// Also immediately calls `run()` handler for current location\nrouter.listen();\n```\n\n## API\n\n### navaid(base, on404)\n\nReturns: `Navaid`\n\n#### base\nType: `String`\u003cbr\u003e\nDefault: `'/'`\n\nThe base pathname for your application. By default, Navaid assumes it's operating on the root.\n\nAll routes will be processed _relative to_ this path (see [`on()`](#onpattern-handler)). Similarly, while [`listen`](#listen)ing, Navaid **will not** intercept any links that don't lead with this `base` pathname.\n\n\u003e **Note:** Navaid will accept a `base` with or without a leading and/or trailing slash, as all cases are handled identically.\n\n#### on404\nType: `Function`\u003cbr\u003e\nDefault: `undefined`\n\nThe function to run if the incoming pathname did not match any of your defined defined patterns.\u003cbr\u003e\nWhen defined, this function will receive the formatted `uri` as its only parameter; see [`format()`](#formaturi).\n\n\u003e **Important:** Navaid ***only*** processes routes that match your `base` path!\u003cbr\u003e\nPut differently, `on404` will never run for URLs that do not begin with `base`.\u003cbr\u003e\nThis allows you to mount _multiple_ Navaid instances on the same page, each with different `base` paths. :wink:\n\n\n### format(uri)\nReturns: `String` or `false`\n\nFormats and returns a pathname relative to the [`base`](#base) path.\n\nIf the `uri` **does not** begin with the `base`, then `false` will be returned instead.\u003cbr\u003e\nOtherwise, the return value will always lead with a slash (`/`).\n\n\u003e **Note:** This is called automatically within the [`listen()`](#listen) and [`run()`](#runuri) methods.\n\n#### uri\nType: `String`\n\nThe path to format.\n\n\u003e **Note:** Much like [`base`](#base), paths with or without leading and trailing slashes are handled identically.\n\n### route(uri, replace)\nReturns: `undefined`\n\nProgrammatically route to a path whilst modifying \u0026 using the `history` events.\n\n#### uri\nType: `String`\n\nThe desired path to navigate.\n\n\u003e **Important:** Navaid will prefix your `uri` with the [`base`](#base), if/when defined.\n\n#### replace\nType: `Boolean`\u003cbr\u003e\nDefault: `false`\n\nIf `true`, then [`history.replaceState`](https://developer.mozilla.org/en-US/docs/Web/API/History_API#The_replaceState()_method) will be used. Otherwise [`history.pushState`](https://developer.mozilla.org/en-US/docs/Web/API/History_API#Adding_and_modifying_history_entries) will be used.\n\nThis is generally used for redirects; for example, redirecting a user away from a login page if they're already logged in.\n\n\n### on(pattern, handler)\nReturns: `Navaid`\n\nDefine a function `handler` to run when a route matches the given `pattern` string.\n\n#### pattern\nType: `String`\n\nThe supported pattern types are:\n\n* static (`/users`)\n* named parameters (`/users/:id`)\n* nested parameters (`/users/:id/books/:title`)\n* optional parameters (`/users/:id?/books/:title?`)\n* any match / wildcards (`/users/*`)\n\n\u003e **Note:** It does not matter if your pattern begins with a `/` — it will be added if missing.\n\n\n#### handler\nType: `Function`\n\nThe function to run when its `pattern` is matched.\n\n\u003e **Note:** This can also be a `Promise` or `async` function, but it's up to you to handle its result/error.\n\nFor `pattern`s with named parameters and/or wildcards, the `handler` will receive an \"params\" object containing the parsed values.\n\nWhen wildcards are used, the \"params\" object will fill a `wild` key with the URL segment(s) that match from that point \u0026 onward.\n\n```js\nlet r = new Navaid();\n\nr.on('/users/:id', console.log).run('/users/lukeed');\n//=\u003e { id: 'lukeed' }\n\nr.on('/users/:id/books/:title?', console.log).run('/users/lukeed/books/narnia');\n//=\u003e { id: 'lukeed', title: 'narnia' }\n\nr.on('/users/:id/jobs/*').run('/users/lukeed/jobs/foo/bar/baz/bat');\n//=\u003e { id: 'lukeed', wild: 'foo/bar/baz/bat' }\n```\n\n### run(uri)\nReturns: `Navaid`\n\nExecutes the matching handler for the specified path.\n\nUnlike `route()`, this does not pass through the `history` state nor emit any events.\n\n\u003e **Note:** You'll generally want to use `listen()` instead, but `run()` may be useful in Node.js/SSR contexts.\n\n#### uri\nType: `String`\u003cbr\u003e\nDefault: `location.pathname`\n\nThe pathname to process. Its matching `handler` (as defined by [`on()`](#onpattern-handler)) will be executed.\n\n### listen(uri?)\nReturns: `Navaid`\n\nAttaches global listeners to synchronize your router with URL changes, which allows Navaid to respond consistently to your browser's \u003ckbd\u003eBACK\u003c/kbd\u003e and \u003ckbd\u003eFORWARD\u003c/kbd\u003e buttons.\n\nThese are the (global) events that Navaid creates and/or responds to:\n\n* popstate\n* replacestate\n* pushstate\n\nNavaid will also bind to any `click` event(s) on anchor tags (`\u003ca href=\"\" /\u003e`) so long as the link has a valid `href` that matches the [`base`](#base) path. Navaid **will not** intercept links that have _any_ `target` attribute or if the link was clicked with a special modifier (eg; \u003ckbd\u003eALT\u003c/kbd\u003e, \u003ckbd\u003eSHIFT\u003c/kbd\u003e, \u003ckbd\u003eCMD\u003c/kbd\u003e, or \u003ckbd\u003eCTRL\u003c/kbd\u003e).\n\n#### uri\nType: `String`\u003cbr\u003e\nDefault: `undefined`\n\n*(Optional)* Any value passed to `listen()` will be forwarded to the underlying [`run()`](#runuri) call.\u003cbr\u003eWhen not defined, `run()` will read the current `location.pathname` value.\n\n### unlisten()\nReturns: `undefined`\n\nDetach all listeners initialized by [`listen()`](#listen).\n\n\u003e **Note:** This method is only available after `listen()` has been invoked.\n\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","funding_links":["https://github.com/sponsors/lukeed"],"categories":["JavaScript","components and libraries","Routing","Routers and URL Utils","Routing [🔝](#readme)","路由"],"sub_categories":["routers","Runner","Reactive Programming","运行器","运行器e2e测试"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fnavaid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukeed%2Fnavaid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fnavaid/lists"}