{"id":27765683,"url":"https://github.com/goodbytes/linkdetector","last_synced_at":"2026-02-09T00:03:04.887Z","repository":{"id":285722054,"uuid":"959114330","full_name":"goodbytes/LinkDetector","owner":"goodbytes","description":"A Java utility that lets you detect where in a text links begin and end.","archived":false,"fork":false,"pushed_at":"2025-04-02T17:49:04.000Z","size":26,"stargazers_count":1,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-20T10:13:39.277Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/goodbytes.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-04-02T09:38:35.000Z","updated_at":"2025-04-02T17:49:08.000Z","dependencies_parsed_at":"2025-04-02T10:36:00.949Z","dependency_job_id":"d16ab3fc-e78a-4c7c-bc13-019c69156ebd","html_url":"https://github.com/goodbytes/LinkDetector","commit_stats":null,"previous_names":["goodbytes/linkdetector"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goodbytes%2FLinkDetector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goodbytes%2FLinkDetector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goodbytes%2FLinkDetector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goodbytes%2FLinkDetector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goodbytes","download_url":"https://codeload.github.com/goodbytes/LinkDetector/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251546664,"owners_count":21606889,"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":"2025-04-29T16:55:12.622Z","updated_at":"2026-02-09T00:03:04.847Z","avatar_url":"https://github.com/goodbytes.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LinkDetector\n\nA Java utility that lets you detect where in plain text a hyperlink begins and ends.\n\nCorrectly identifying the start and end location of a link in text can be tricky, especially when those links either \n_include_ or are _surrounded by_ parenthesis, followed by a comma, and so on:\n- `https://example.org/foo,` instead of `https://example.org/foo` (from a text like `... on https://example.org/foo, where ...`).\n- `https://example.org/foo)` instead of `https://example.org/foo` (from a text like `... the webpage (https://example.org/foo) where ...` ).\n\nThese often lead to browsers being opened to invalid URLs, causing end-users to see 404 pages or other errors.\n\nThis project simplifies parsing the correct start and end of links in text, which helps avoid such issues.\n\n## Usage\n\nThe distributable is available through the Maven central repository. You can then define this project to be a dependency of your project, like so:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003enl.goodbytes.util\u003c/groupId\u003e\n    \u003cartifactId\u003elinkdetector\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.0\u003c/version\u003e \u003c!-- Please remember to check if this is the latest, as this example could be outdated. --\u003e\n\u003c/dependency\u003e\n```\n\nTo use the utility in your code, invoke the `parse` method of the `LinkDetector` class, as shown below. This will split\nup the text in fragments (returned in a list). For each fragment, a start and end index is provided, and defines if it does or does\nnot represent a link.\n\n```java\nfinal String input = \"Please find more information in the corresponding page on \"\n    + \"Wikipedia (https://en.wikipedia.org/wiki/Ambiguity_(disambiguation)). Let me \"\n    + \"know if you have questions!\";\n\nfinal List\u003cFragment\u003e fragments = LinkDetector.parse(input);\n\nfor (final Fragment fragment : fragments)\n{\n    System.out.println(\"Fragment starting at index \" + fragment.startIndex()\n        + \", ending at index \" + fragment.endIndex() + \" (exclusive) \"\n        + (fragment.isLink() ? \"is\" : \"is not\") + \" a link:\");\n    System.out.println(\"\\t\" + fragment);\n    System.out.println();\n}\n```\n\nThe example code above generates the following output:\n```\nFragment starting at index 0, ending at index 69 (exclusive) is not a link:\n\tPlease find more information in the corresponding page on Wikipedia (\n\nFragment starting at index 69, ending at index 125 (exclusive) is a link:\n\thttps://en.wikipedia.org/wiki/Ambiguity_(disambiguation)\n\nFragment starting at index 125, ending at index 162 (exclusive) is not a link:\n\t). Let me know if you have questions!\n```\n\n## Build / Compilation\n\nThis project should be compatible with any version of Java that is not _ancient_. It _should_ be compatible with \nJava 1.4, but to circumvent some issues with modern build tooling, its project descriptor defines 1.8.\n\nThe project can be built using standard [Maven](https://maven.apache.org/) invocations, like this:\n\n```bash\nmvn clean package\n```\n\nThe project does not use any external dependencies (although for testing, the [JUnit](https://junit.org/) library is\nadded to the test scope of the build process).\n\n## Attribution\nThis is but a simple Java wrapper around a regular expression that was provided by [Wiktor Kwapisiewicz](https://metacode.biz/@wiktor).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoodbytes%2Flinkdetector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoodbytes%2Flinkdetector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoodbytes%2Flinkdetector/lists"}