{"id":21077981,"url":"https://github.com/ryanburnette/htmlassetref","last_synced_at":"2025-03-14T04:12:07.377Z","repository":{"id":171328882,"uuid":"647757794","full_name":"ryanburnette/htmlassetref","owner":"ryanburnette","description":null,"archived":false,"fork":false,"pushed_at":"2023-05-31T22:20:41.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T23:16:22.215Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryanburnette.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":"2023-05-31T13:09:23.000Z","updated_at":"2023-05-31T22:14:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"09b83d4f-efd5-4f84-9314-b62b751e7bcc","html_url":"https://github.com/ryanburnette/htmlassetref","commit_stats":null,"previous_names":["ryanburnette/html-asset-ref","ryanburnette/htmlassetref"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanburnette%2Fhtmlassetref","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanburnette%2Fhtmlassetref/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanburnette%2Fhtmlassetref/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanburnette%2Fhtmlassetref/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanburnette","download_url":"https://codeload.github.com/ryanburnette/htmlassetref/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243521288,"owners_count":20304187,"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-11-19T19:38:55.796Z","updated_at":"2025-03-14T04:12:07.355Z","avatar_url":"https://github.com/ryanburnette.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# htmlassetref\n\n`htmlassetref` is a Go package that enables the modification of URL references within HTML content. It offers a straightforward and convenient approach to identify HTML tags with attributes like src, href, or srcset that reference URLs, allowing for easy customization based on a callback function. With `htmlassetref`, developers can efficiently update and manipulate URL references in HTML, facilitating tasks such as rewriting asset URLs, handling path adjustments, or implementing custom transformations.\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/ryanburnette/htmlassetref\"\n)\n\nfunc main() {\n\t// Sample HTML content\n\thtml := `\u003clink rel=\"stylesheet\" href=\"styles.css\"\u003e\n\t         \u003cscript src=\"script.js\"\u003e\u003c/script\u003e\n\t         \u003cimg src=\"image.jpg\" alt=\"Image\"\u003e`\n\n\t// Call UpdateAssetRefs with a callback function to update the references\n\tupdatedHTML := htmlassetref.UpdateAssetRefs(html, func(ref string) string {\n\t\t// Modify the reference as needed (e.g., add a version suffix)\n\t\treturn ref + \"?v=1.0\"\n\t})\n\n\t// Print the updated HTML\n\tfmt.Println(updatedHTML)\n}\n\n```\n\n## Test\n\nThe reliability of this package is maintained through the test. The\n`_content.html` markup in this project should contain all possible examples of\nHTML tags that reference a downloadable asset. The tests ensure that all\napplicable tags are being found and their correct references returned and then\nmodified by the callback.\n\n```shell\ngo test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanburnette%2Fhtmlassetref","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanburnette%2Fhtmlassetref","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanburnette%2Fhtmlassetref/lists"}