パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v1.0.0

uri

URI の構築およびパースに使用するユーティリティで、RFC 6570 で定義された URI テンプレートの解析もサポートしています。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
48.4万
いいね数
26
Pub ポイント
145

パッケージをインストール

flutter pub add uri

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

uri パッケージは、Dart アプリケーションにおける URI の構築、解析、および操作に役立つユーティリティを提供します。RFC 6570準拠の URI テンプレート解析をサポートしており、変数を含む動的な URL の生成が可能です。すべての主要プラットフォームで使用できるように設計されており、HTTP クライアントやウェブサービス統合にスムーズに統合されます。Google によってメンテナンスされており、Flutter および Dart プロジェクトにおける複雑な URI 操作に対する軽量かつ信頼性の高いソリューションを提供しています。

用途

  • 動的API URLの構築
  • URIからクエリパラメータを解析する
  • 変数を含む URI テンプレートの拡張
  • 相対URIと絶対URIの処理
  • HTTP クライアントとの統合
  • URI 構造の検証

主な機能

  • RFC 6570 URI テンプレートサポート
  • 堅牢な解析と構築
  • クロスプラットフォーム互換性
  • 軽量で効率的
  • クエリ文字列の操作をサポートしています
  • カスタム URI ロジック用に拡張可能

適している対象

  • API クライアント
  • Webサービス統合
  • URLルーティングシステム
  • データ取得パイプライン
  • バックエンド通信レイヤー
  • HTTP インタラクションのテスト

注意事項

  • 特殊文字のエンコーディングを手動で処理する必要があります
  • 構文を超えた完全なURL検証には意図されていません
  • URIレベルの操作に限定され、完全なHTTPリクエストではない
  • 組み込みのキャッシュや再試行メカニズムなし
  • テンプレート構文の正しい使用に依存する
  • 完全なHTTPワークフローを実現するには、httpパッケージとの連携が必要になる場合があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

ci

Utilities for working with URIs in Dart, mostly parsing and generating URIs.

UriPattern

UriPattern is an interface for classes that match and parse URIs, much like the Pattern is for Strings. It defines the methods bool matches(Uri uri) and UriMatch match(Uri uri).

UriMatch

UriMatch is the result of UriPattern.match(). It contains the parameters parsed out of a URI and the "rest" of the URI left over after parsing, which is useful for parsing a single URI with multiple relative URI patterns that form a hierarchy.

UriTemplate

UriTemplate is an implementation of RFC 6570 URI Templates. URI Templates are useful for generating URIs from data. UriTemplates are created from a template string, and then expanded with data to generate a URI:

var template = UriTemplate("http://example.com/~{user}/");
String fredUri = template.expand({'user': 'fred'});
print(fredUri); // prints: http://example.com/~fred/
Syntax

URI templates are strings made up of fixed and variable parts. The variable parts are described with expressions, which are places within single curly-braces: { and }.

Expressions consist of an optional operator and a comma-separated list of variable specifications_. Variable specifications consist of a variable name and an optional modifier. The operator applies to the whole expression and controls how reserved characters are expanded, the prefix and separator, if any, applied to the expansion, and whether to expand the variable as a key/value pair. Modifiers apply to each variable in the expression and allow truncating the value, or "exploding" list and maps into multiple key/value pairs.

Examples
  • http://example.com/~{username}/
  • http://example.com/dictionary/{term:1}/{term}
  • http://example.com/search{?q,lang}
Operators

URI template expansions does more than simple variable replacement, it has facilities for generating paths, fragments, query strings and more. To control the expansion, expressions can use one of the supported operators:

Operator Description
none Simple string expansion
+ Reserved string expansion
# Fragment expansion
. Label expansion, dot-prefixed
/ Path segments, slash-prefixed
; Path-style parameters, semicolon-prefixed
? Form-style query, ampersand-separated
& Form-style query continuation
Modifiers

Modifiers control

Modifier Description
none Default expansion
:n Prefix: use only the first n characters of the value
* "Explode" the lists and maps into key/value pairs

UriParser

UriParser parses URIs according to a UriTemplate, extracting parameters based on the variables defined in the template.

Since URI Templates are not designed to be parsable, only a restricted subset of templates can be used for parsing.

Parsable templates have the following restrictions over expandable templates:

  • URI components must come in order: scheme, host, path, query, fragment. There can only be one of each component.
  • Path expressions can only contain one variable.
  • Multiple expressions must be separated by a literal.
  • Only the following operators are supported: none, +, #, ?, &
  • Default and + operators are not allowed in query or fragment components.
  • Queries can only use the ? or & operator.
  • The ? operator can only be used once.
  • Fragments can only use the # operator

UriBuilder

UriBuilder is mutable container of URI components for incrementally building Uris.

カテゴリー

依存関係

依存関係一覧 2 件

ソースリポジトリ

このパッケージを使用しているプロジェクト