{"id":19773487,"url":"https://github.com/dmitryfillo/uripathscanf","last_synced_at":"2026-06-14T05:31:46.421Z","repository":{"id":68115008,"uuid":"153626819","full_name":"DmitryFillo/UriPathScanf","owner":"DmitryFillo","description":"Reversed String.Format for URI path","archived":false,"fork":false,"pushed_at":"2019-03-15T16:59:49.000Z","size":62,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T11:45:40.244Z","etag":null,"topics":["path","scanf","string-format","uri","uripathscanf"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DmitryFillo.png","metadata":{"files":{"readme":"README.rst","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":"2018-10-18T13:17:45.000Z","updated_at":"2018-10-30T10:42:15.000Z","dependencies_parsed_at":"2023-03-22T19:31:58.889Z","dependency_job_id":null,"html_url":"https://github.com/DmitryFillo/UriPathScanf","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/DmitryFillo/UriPathScanf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DmitryFillo%2FUriPathScanf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DmitryFillo%2FUriPathScanf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DmitryFillo%2FUriPathScanf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DmitryFillo%2FUriPathScanf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DmitryFillo","download_url":"https://codeload.github.com/DmitryFillo/UriPathScanf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DmitryFillo%2FUriPathScanf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34310801,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-14T02:00:07.365Z","response_time":62,"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":["path","scanf","string-format","uri","uripathscanf"],"created_at":"2024-11-12T05:09:51.282Z","updated_at":"2026-06-14T05:31:46.405Z","avatar_url":"https://github.com/DmitryFillo.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"==============\r\nURI path scanf\r\n==============\r\n\r\n.. image:: https://travis-ci.com/DmitryFillo/UriPathScanf.svg?branch=master\r\n     :target: https://travis-ci.com/DmitryFillo/UriPathScanf\r\n\r\nReversed String.Format for URI path.\r\n\r\nYou can describe URI path like ``/some/path/{id}/some.html`` and parse it to the model like ``{ type: \"someUri\", id: [id] }``. Supports query string.\r\n\r\n.. contents::\r\n\r\nMotivation\r\n==========\r\n\r\nThis package is useful for you if:\r\n\r\n* You need to get metadata (identifiers) from URI paths, e.g. to provide API to not to couple some parts of the system with UI specific information.\r\n* You're going to encode data in \"URI path format\", e.g. ``/{identifierOne}/{identifierTwo}``, and then you're going to decode them to ``IDictionary\u003cstring, string\u003e`` or models.\r\n\r\nInstall\r\n=======\r\n\r\nInstall `UriPathScanf \u003chttps://www.nuget.org/packages/UriPathScanf\u003e`_ via nuget.\r\n\r\nUsage\r\n=====\r\n\r\n.. code:: c#\r\n\r\n  var descriptors = new[]\r\n  {\r\n      new UriPathDescriptor(\"/path/some/{varOne}\", \"firstType\"),\r\n      new UriPathDescriptor(\"/path/some/{someVar}/{someVar2}\", \"secondType\"),\r\n  };\r\n\r\n  var uriPathScanf = new UriPathScanf(descriptors);\r\n\r\n  // scan some URI path\r\n  var result = uriPathScanf.Scan(\"/path/some/xxx?a=1\");\r\n  \r\n  // result.UriType == \"firstType\"\r\n  // result.Meta is Dictionary\u003cstring, string\u003e with \"varOne\" == \"xxx\" and \"qs__a\" = \"1\" \r\n  \r\n  // scan some URI path\r\n  result = uriPathScanf.Scan(\"/path/some/xxx/123y////?a=1\");\r\n  \r\n  // result.UriType == \"secondType\"\r\n  // result.Meta is Dictionary\u003cstring, string\u003e with \"someVar\" == \"xxx\", \"someVar2\" == \"123y\" and \"qs__a\" = \"1\" \r\n  \r\nTyped descriptors:\r\n\r\n.. code:: c#\r\n\r\n  class Meta : IUriPathMetaModel\r\n  {\r\n      [UriMeta(\"someVar\")]\r\n      public string SomeVar { get; set; }\r\n\r\n      [UriMeta(\"someVar2\")]\r\n      public string SomeVar2 { get; set; }\r\n\r\n      [UriMetaQuery(\"x\")]\r\n      public string SomeVarQueryString { get; set; }\r\n   }\r\n\r\n  var descriptors = new[]\r\n  {\r\n      new UriPathDescriptor(\"/path/some/{someVar}/{someVar2}\", \"firstType\", typeof(Meta)),\r\n      new UriPathDescriptor(\"/some/path/{someVar}/{someVar2}\", \"secondType\", typeof(Meta)),\r\n  };\r\n\r\n  var uriPathScanf = new UriPathScanf(descriptors);\r\n\r\n  var result = uriPathScanf.Scan\u003cMeta\u003e(\"/path/some/1/2\");\r\n  \r\n  // result.UriType == \"firstType\"\r\n  // result.Meta.SomeVar == 1\r\n  // result.Meta.SomeVar2 == 2\r\n  // result.Meta.SomeVarQueryString = null\r\n  \r\n  result = uriPathScanf.Scan\u003cMeta\u003e(\"/some/path/1/2/?x=23\u0026b=4\");\r\n  \r\n  // result.UriType == \"secondType\"\r\n  // result.Meta.SomeVar == 1\r\n  // result.Meta.SomeVar2 == 2\r\n  // result.Meta.SomeVarQueryString = \"23\"\r\n  \r\nDiffrenently typed descriptors:\r\n\r\n.. code:: c#\r\n\r\n  class Meta : IUriPathMetaModel\r\n  {\r\n      [UriMeta(\"someVar\")]\r\n      public string SomeVar { get; set; }\r\n\r\n      [UriMeta(\"someVar2\")]\r\n      public string SomeVar2 { get; set; }\r\n  }\r\n   \r\n  class Meta2 : IUriPathMetaModel\r\n  {\r\n      [UriMetaQuery(\"x\")]\r\n      public string X { get; set; }\r\n  }\r\n\r\n  var descriptors = new[]\r\n  {\r\n      new UriPathDescriptor(\"/path/some/{someVar}/{someVar2}\", \"firstType\", typeof(Meta)),\r\n      new UriPathDescriptor(\"/some/path/\", \"secondType\", typeof(Meta2)),\r\n  };\r\n\r\n  var uriPathScanf = new UriPathScanf(descriptors);\r\n\r\n  var result = uriPathScanf.Scan\u003cMeta\u003e(\"/path/some/1/2\");\r\n  \r\n  // result.UriType == \"firstType\"\r\n  // result.Meta.SomeVar == 1\r\n  // result.Meta.SomeVar2 == 2\r\n  \r\n  result = uriPathScanf.Scan\u003cMeta\u003e(\"/some/path/1/2/?x=23\u0026b=4\");\r\n  \r\n  // result == null\r\n  \r\n  result = uriPathScanf.Scan\u003cMeta\u003e(\"/some/path/\");\r\n  \r\n  // result == null\r\n  \r\n  result = uriPathScanf.Scan\u003cMeta2\u003e(\"/some/path/\");\r\n  \r\n  // result.UriType == \"secondType\"\r\n  // result.Meta.X == null\r\n  \r\n  result = uriPathScanf.ScanAll(\"/some/path/x=x\");\r\n  \r\n  // result.UriType == \"secondType\"\r\n  // result.Meta is object\r\n  \r\n  // You can use type pattern matching (is / switch case)\r\n  // e.g. result.Meta is Meta2 \r\n  // or these methods:\r\n  \r\n  result.TryCast\u003cMeta\u003e(out var resultCastedToMeta)\r\n  \r\n  // resultCastedToMeta == null\r\n  \r\n  result.TryCast\u003cMeta2\u003e(out var resultCastedToMeta2) \r\n  \r\n  // resultCastedToMeta2 is Meta2\r\n  // resultCastedToMeta2.X = \"x\"\r\n  \r\nTyped and non-typed descriptors:\r\n\r\n.. code:: c#\r\n\r\n  class Meta : IUriPathMetaModel\r\n  {\r\n      [UriMeta(\"someVar\")]\r\n      public string SomeVar { get; set; }\r\n\r\n      [UriMeta(\"someVar2\")]\r\n      public string SomeVar2 { get; set; }\r\n  }\r\n\r\n  var descriptors = new[]\r\n  {\r\n      new UriPathDescriptor(\"/path/some/{someVar}/{someVar2}\", \"someType\", typeof(Meta)),\r\n      new UriPathDescriptor(\"/some/path/\", \"someType\"),\r\n  };\r\n\r\n  var uriPathScanf = new UriPathScanf(descriptors);\r\n\r\n  var result = uriPathScanf.ScanAll(\"/path/some/1/2\");\r\n  \r\n  // result.UriType == \"someType\"\r\n  // result.Meta is object\r\n  // result.Meta.SomeVar2 == 2\r\n    \r\n  // You can use type pattern matching (is / switch case)\r\n  // e.g. result.Meta is Meta\r\n  // or these methods:\r\n  \r\n  result.TryCast\u003cMeta\u003e(out var resultCastedToMeta)\r\n  \r\n  // resultCastedToMeta is Meta\r\n  // resultCastedToMeta.SomeVar = \"1\"\r\n  // resultCastedToMeta.SomeVar2 = \"2\"\r\n  \r\n  result.TryCastToDict(out var resultCastedToDict) \r\n  \r\n  // resultCastedToDict == null\r\n  \r\n  result = uriPathScanf.ScanAll(\"/some/path/?x=3\u0026m=n\");\r\n  \r\n  // result.UriType == \"someType\"\r\n  // result.Meta is object\r\n  \r\n  result.TryCastToDict(out resultCastedToDict) \r\n  \r\n  // resultCastedToDict is Dictionary\u003cstring, string\u003e with keys \"qs__x\" and \"qs__m\"\r\n  \r\n  result = uriPathScanf.Scan\u003cMeta\u003e(\"/path/some/1/2\");\r\n  \r\n  // result.UriType == \"someType\"\r\n  // result.Meta is Meta\r\n  // result.Meta.SomeVar == 1\r\n  // result.Meta.SomeVar2 = 2\r\n  \r\n  result = uriPathScanf.Scan\u003cMeta\u003e(\"/some/path/?x=3\u0026m=n\");\r\n  \r\n  // result = null\r\n\r\n\r\nExamples\r\n========\r\n\r\nCheck examples in the project ``UriPathScanf.Example``.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmitryfillo%2Furipathscanf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmitryfillo%2Furipathscanf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmitryfillo%2Furipathscanf/lists"}