{"id":29066907,"url":"https://github.com/rhaiscript/rhai-url","last_synced_at":"2025-06-27T10:08:55.089Z","repository":{"id":61939727,"uuid":"556417863","full_name":"rhaiscript/rhai-url","owner":"rhaiscript","description":"Provides url access for the Rhai scripting language.","archived":false,"fork":false,"pushed_at":"2023-10-25T12:43:38.000Z","size":50,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-09T21:26:50.573Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","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/rhaiscript.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-10-23T20:03:00.000Z","updated_at":"2023-11-04T18:33:56.000Z","dependencies_parsed_at":"2022-10-23T21:30:27.333Z","dependency_job_id":"5d4b2917-2ad5-4993-a3dd-e5a90316581b","html_url":"https://github.com/rhaiscript/rhai-url","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/rhaiscript/rhai-url","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhaiscript%2Frhai-url","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhaiscript%2Frhai-url/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhaiscript%2Frhai-url/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhaiscript%2Frhai-url/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rhaiscript","download_url":"https://codeload.github.com/rhaiscript/rhai-url/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhaiscript%2Frhai-url/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262235784,"owners_count":23279567,"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-06-27T10:08:53.269Z","updated_at":"2025-06-27T10:08:55.076Z","avatar_url":"https://github.com/rhaiscript.png","language":"Rust","readme":"# About `rhai-url`\n\n[![License](https://img.shields.io/crates/l/rhai-url)](https://github.com/license/rhaiscript/rhai-url)\n[![crates.io](https://img.shields.io/crates/v/rhai-url?logo=rust)](https://crates.io/crates/rhai-url/)\n[![crates.io](https://img.shields.io/crates/d/rhai-url?logo=rust)](https://crates.io/crates/rhai-url/)\n[![API Docs](https://docs.rs/rhai-url/badge.svg?logo=docs-rs)](https://docs.rs/rhai-url/)\n\nThis crate provides `url::Url` access for the [Rhai] scripting language.\n\n## Usage\n\n### `Cargo.toml`\n\n```toml\n[dependencies]\nrhai-url = \"0.0.5\"\n```\n\n### [Rhai] script\n\n```js\n// create a new Url\nlet url = Url(\"http://example.com/?q=query\");\n\n// get the absolute url as a string\nprint(url.href); // print 'http://example.com/?q=query'\nprint(url.to_string()); // print 'http://example.com/?q=query'\n\n// get the url query string, without the leading ?\nprint(url.query); // print 'q=query'\n\n// get the url fragment\nprint(url.fragment); // print ''\n\n// hash is an alias of fragment\nprint(url.hash); // print ''\n\n// clear the query\nurl.query_clear();\nprint(url.query); // print ''\n\n// remove a query key\nurl.query_remove(\"q\");\n\n// query_remove with no arguments will clear the query string\nurl.query_remove();\n\n// adds a query key value pair into the query string\nurl.query_append(\"q\", \"name\");\n\n```\n\nYou can see an example on how to use those function in the [tests](tests/url.rs).\n\n### Rust source\n\n```rust\nuse rhai::{Engine, EvalAltResult};\nuse rhai::packages::Package;\nuse rhai_url::UrlPackage;\nuse url::Url;\n\nfn main() -\u003e Result\u003c(), Box\u003cEvalAltResult\u003e\u003e {\n    // Create Rhai scripting engine\n    let mut engine = Engine::new();\n\n    // Create url package and add the package into the engine\n    let package = UrlPackage::new();\n    package.register_into_engine(\u0026mut engine);\n\n    // Print the url\n    let url = engine.eval::\u003cUrl\u003e(r#\"Url(\"http://test.dev/\")\"#)?;\n\n    println!(\"{}\", url);\n\n    // Print the url string, equivalent of to_string()\n    let href = engine.eval::\u003cString\u003e(r#\"Url(\"http://test.dev/\").href\"#)?;\n\n    println!(\"{}\", href);\n\n    Ok(())\n}\n```\n\n## Features\n\n|  Feature   | Default  | Description                                          |\n| :--------: | :------: | ---------------------------------------------------- |\n| `array`    | enabled  | Enables support for [Rhai] `Array`                   |\n| `metadata` | disabled | Enables support for generating package documentation |\n\n[Rhai]: https://rhai.rs","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhaiscript%2Frhai-url","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frhaiscript%2Frhai-url","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhaiscript%2Frhai-url/lists"}