{"id":36894455,"url":"https://github.com/forderation/uruki","last_synced_at":"2026-01-12T15:40:51.506Z","repository":{"id":62867552,"uuid":"561012197","full_name":"forderation/uruki","owner":"forderation","description":"uri / url parser wrapped with net/url. adjusted to safe mutate data with options of restricted scheme and automatically internal encode data.","archived":false,"fork":false,"pushed_at":"2023-09-04T12:38:43.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-06-20T11:56:38.909Z","etag":null,"topics":["go","parser","query-builder","urllib"],"latest_commit_sha":null,"homepage":"","language":"Go","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/forderation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2022-11-02T18:47:30.000Z","updated_at":"2022-11-02T18:50:55.000Z","dependencies_parsed_at":"2024-06-20T11:06:48.620Z","dependency_job_id":"26312076-6c7a-42bb-a9cf-b36c4169d160","html_url":"https://github.com/forderation/uruki","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/forderation/uruki","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forderation%2Furuki","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forderation%2Furuki/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forderation%2Furuki/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forderation%2Furuki/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/forderation","download_url":"https://codeload.github.com/forderation/uruki/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forderation%2Furuki/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28341269,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T12:22:26.515Z","status":"ssl_error","status_checked_at":"2026-01-12T12:22:10.856Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["go","parser","query-builder","urllib"],"created_at":"2026-01-12T15:40:51.139Z","updated_at":"2026-01-12T15:40:51.486Z","avatar_url":"https://github.com/forderation.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![godoc](https://godoc.org/github.com/golang/mock/gomock?status.svg)](https://pkg.go.dev/github.com/forderation/uruki)\n![github actions](https://github.com/forderation/uruki/actions/workflows/go.yml/badge.svg)\n# URUKI\n\n\u003cspan style=\"color:pink\"\u003eURUKI\u003c/span\u003e (URi qUicK buIlder) uri / url parser wrapped with net/url. adjusted to safe mutate data with options of restricted scheme and automatically internal encode data. ref: https://en.wikipedia.org/wiki/Uniform_Resource_Identifier\n\nBackground using this wrapper:\n- quick update part of uri, because there is multi step if we using net/url to add / update / delete part of uri\n- keep consistent all uri parts (scheme, host, port, path, query, fragment)\n- get result of uri as string with automatically encoding\n- restrict space encode\n\nFeature supports:\n- automatically encode by default setting\n- delete key query without force encode values\n- restricted scheme url, and encoding method\n- multi add key query param\n- set / get fragment\n- update base url with validation mechanism\n\n## Uruki Option\nOption while initiate builder\n\n| Field | Type | Description |\n|-|-|-|\n| URL | string | URL existing to parse |\n| RestrictScheme | []string | default no restrict scheme, for example if you want restrict scheme url only into http, https, and tokopedia. can use []string{\"http\", \"https\", \"tokopedia\"}|\n| DefaultSpaceEncode | SpaceEncoding | space encoding method while escape query, refer to SpaceEncoding list below, default is keep space as is|\n| UseEscapeAutomateURL | bool | automate escape existing query while init builder / SetURL(uri string), default false|\n\nSpaceEncoding method build in\n- WithoutEncoding = keep space as is\n- PercentTwentyEncoding = change space into %20\n- PlusEncoding = change space into +\n\n## Example Initiate\n\n```go\n// without using options\n\nub, err := NewBuilder()\nif err != nil {\n    fmt.Println(err)\n    return\n}\ngot := ub.GetURLResult()\n\n// got = \"\"\n```\n\n```go\n// using options without UseEscapeAutomateURL\n\nub, err := NewBuilder(Option{\n    URL:                   \"https://www.tokopedia.com/search?condition=1\u0026fcity=174,175,176,177,178,179\u0026navsource=\u0026rf=true\u0026rt=4,5\u0026srp_component_id=02.01.00.00\u0026srp_page_id=\u0026srp_page_title=\u0026st=product\u0026q=macbook air m2\",\n    UseEscapeAutomateURL: false,\n})\nif err != nil {\n    fmt.Println(err)\n    return\n}\ngot = ub.GetURLResult()\n\n// got = \"https://www.tokopedia.com/search?condition=1\u0026fcity=174,175,176,177,178,179\u0026navsource=\u0026rf=true\u0026rt=4,5\u0026srp_component_id=02.01.00.00\u0026srp_page_id=\u0026srp_page_title=\u0026st=product\u0026q=macbook air m2\"\n```\n\n```go\n// using options with UseEscapeAutomateURL and PercentTwentyEncoding\n\nub, err := NewBuilder(Option{\n    URL:                   \"https://www.tokopedia.com/search?condition=1\u0026fcity=174,175,176,177,178,179\u0026navsource=\u0026rf=true\u0026rt=4,5\u0026srp_component_id=02.01.00.00\u0026srp_page_id=\u0026srp_page_title=\u0026st=product\u0026q=macbook air m2\",\n    UseEscapeAutomateURL: true,\n    DefaultSpaceEncode:    PercentTwentyEncoding,\n})\nif err != nil {\n    fmt.Println(err)\n    return\n}\ngot = ub.GetURLResult()\n\n// got = \"https://www.tokopedia.com/search?condition=1\u0026fcity=174%2C175%2C176%2C177%2C178%2C179\u0026navsource=\u0026rf=true\u0026rt=4%2C5\u0026srp_component_id=02.01.00.00\u0026srp_page_id=\u0026srp_page_title=\u0026st=product\u0026q=macbook%20air%20m2\"\n```\n\n```go\n// using options with UseEscapeAutomateURL, PercentTwentyEncoding and RestrictScheme\n_, err = NewBuilder(Option{\n    URL:                   \"http://www.tokopedia.com/search?condition=1\u0026fcity=174,175,176,177,178,179\u0026navsource=\u0026rf=true\u0026rt=4,5\u0026srp_component_id=02.01.00.00\u0026srp_page_id=\u0026srp_page_title=\u0026st=product\u0026q=macbook air m2\",\n    UseEscapeAutomateURL: true,\n    DefaultSpaceEncode:    PercentTwentyEncoding,\n    RestrictScheme:        []string{\"https\"},\n})\n// this will be error because we restrict scheme only https\nif err != nil {\n    fmt.Println(err)\n    return\n}\n```\n\n## Featured List\n\n### AddQueryParam\nadd query parameter values, internally will be encode the value of query, options param:\n- Key string = key query\n- Val string = value query\n- SpaceEnc string = specify space encode if you use custom encoding\n- UseDefaultEncode bool = if you want using DefaultSpaceEncoding as SpaceEnc\n```go\n// using ampersand value and some without encoding space\nub, err := NewBuilder(Option{\n    URL:                \"https://tokopedia.com/search\",\n    DefaultSpaceEncode: PercentTwentyEncoding,\n})\nif err != nil {\n    fmt.Println(err)\n    return\n}\nerr := ub.AddQueryParam(AddQueryParamOpt{Key:\"q\",Val:\"produk p\u0026g\",SpaceEnc:PlusEncoding})\nif err != nil {\n    fmt.Println(err)\n    return\n}\nurl := ub.GetURLResult()\n// url = \"https://tokopedia.com/search?q=produk+p%26g\"\n```\n\n### SetBaseURL\nchange or update existing of base url only host and port\n```go\nub, err := NewBuilder(Option{\n    URL:                \"https://www.tokopedia.com/acmic/acmic-usb-c-to-lightning-adapter-iphone-converter-connector-konektor?extParam=ivf%3Dfalse%26src%3Dsearch%26whid%3D13355454\",\n    DefaultSpaceEncode: PercentTwentyEncoding,\n    RestrictScheme:     []string{\"https\", \"tokopedia\"},\n})\nerr = ub.SetBaseURL(\"tokopedia://\")\nif err != nil {\n    fmt.Println(err)\n    return\n}\ngotURL := ub.GetURLResult()\n// url = \"tokopedia://acmic/acmic-usb-c-to-lightning-adapter-iphone-converter-connector-konektor?extParam=ivf%3Dfalse%26src%3Dsearch%26whid%3D13355454\"\n```\n\n### SetPath\nchange or update path only of url\n```go\nub, err := NewBuilder(Option{\n    URL:                \"https://www.tokopedia.com/acmic/acmic-usb-c-to-lightning-adapter-iphone-converter-connector-konektor?extParam=ivf%3Dfalse%26src%3Dsearch%26whid%3D13355454\",\n    DefaultSpaceEncode: PercentTwentyEncoding,\n})\nif err != nil {\n    fmt.Println(err)\n    return\n}\nub.SetPath(\"/iphoneos/acmic-konektor\")\ngotURL := ub.GetURLResult()\n// url = \"https://www.tokopedia.com/iphoneos/acmic-konektor?extParam=ivf%3Dfalse%26src%3Dsearch%26whid%3D13355454\"\n```\n\n### SetFragment\ncreate / update existing fragment for references, without '#'. options:\n- Fragment string = fragment value\n- SpaceEnc string = specify space encode if you use custom encoding\n- UseDefaultEncode bool = if you want using DefaultSpaceEncoding as SpaceEnc\n```go\nub, err := NewBuilder(Option{\n    URL:                \"https://tokopedia.com/discovery\",\n    DefaultSpaceEncode: PercentTwentyEncoding,\n})\nif err != nil {\n    fmt.Println(err)\n    return\n}\nub.SetFragment(SetFragmentOpt{Fragment: \"top 10\", SpaceEnc: PlusEncoding})\ngotURL := ub.GetURLResult()\n// url = \"https://tokopedia.com/discovery#top+10\"\n```\n\n### DeleteKeyQuery\ndelete key query parameter if exist\n```go\nub, err := NewBuilder(Option{\n    URL:                \"https://www.tokopedia.com/search?st=product\u0026q=produck%20p%26g\u0026srp_component_id=01.07.00.00\u0026srp_page_id=\u0026srp_page_title=\u0026navsource=\u0026=exist_val_empty_key\",\n    DefaultSpaceEncode: PercentTwentyEncoding,\n})\nif err != nil {\n    fmt.Println(err)\n    return\n}\nub.DeleteKeyQuery(\"st\")\nub.DeleteKeyQuery(\"srp_page_id\")\nub.DeleteKeyQuery(\"navsource\")\nurl := ub.GetURLResult()\n// url = \"https://www.tokopedia.com/search?q=produck%20p%26g\u0026srp_component_id=01.07.00.00\u0026srp_page_title=\u0026=exist_val_empty_key\"\n```\n\n### SetURL\nreplace all url with new url based on parameter, if error keep old url\n```go\nub, err := NewBuilder(Option{\n    URL:                \"https://www.tokopedia.com/acmic/acmic-usb-c-to-lightning-adapter-iphone-converter-connector-konektor?extParam=ivf%3Dfalse%26src%3Dsearch%26whid%3D13355454\",\n    DefaultSpaceEncode: PercentTwentyEncoding,\n    RestrictScheme:     []string{\"https\", \"tokopedia\"},\n})\nif err != nil {\n    fmt.Println(err)\n    return\n}\nerr = ub.SetURL(\"tokopedia://search?q=p+g\u0026source=search#bottom\")\nif err != nil {\n    fmt.Println(err)\n    return\n}\nurl := ub.GetURLResult()\n// url = \"tokopedia://search?q=p+g\u0026source=search#bottom\"\n\n// expect error because scheme changes into http\nerr = ub.SetURL(\"http://www.tokopedia.com/now\")\nif err != nil {\n    fmt.Println(err)\n}\n```\n\n### DeleteFragment\nremove existing fragment if any\n```go\nub, err := NewBuilder(Option{\n\t\tURL:                \"https://tokopedia.com/discovery#top\",\n\t\tDefaultSpaceEncode: PercentTwentyEncoding,\n\t})\nif err != nil {\n    fmt.Println(err)\n    return\n}\nub.DeleteFragment()\nurl := ub.GetURLResult()\n// url = \"https://tokopedia.com/discovery\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforderation%2Furuki","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforderation%2Furuki","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforderation%2Furuki/lists"}