Code Monkey home page Code Monkey logo

uri_parser's Introduction

package:uri_parser

๐Ÿ”— A minimal & safe utility to parse URIs.

Install

Add in your pubspec.yaml.

dependencies:
  uri_parser: ^1.0.0

Example

Parse or Identify

final parser = URIParser('C:/Windows/System32');
print(parser.type);            // URIType.directory
print(parser.file);            // null
print(parser.directory);       // Directory: 'C:/Windows/System32'
print(parser.uri);             // null
final parser = URIParser('C:\Windows\explorer.exe');
print(parser.type);            // URIType.file
print(parser.file);            // File: 'C:/Windows/explorer.exe'
print(parser.directory);       // null
print(parser.uri);             // null
final parser = URIParser('file://C:/Windows/explorer.exe');
print(parser.type);            // URIType.file
print(parser.file);            // File: 'C:/Windows/explorer.exe'
print(parser.directory);       // null
print(parser.uri);             // null
final parser = URIParser('https://www.example.com/test');
print(parser.type);            // URIType.network
print(parser.file);            // null
print(parser.directory);       // null
print(parser.uri);             // https://www.example.com/test

Validate or Get Uri

final parser = URIParser('C:\Windows\explorer.exe');
final bool valid = parser.validate();
final Uri result = parser.result;

Why

First of all, this is built with requirements of Harmonoid in mind.

Being a music player, there's a great involvement of URIs everywhere. Since, users can give their inputs in wide range of formats, this is built to handle that while providing some finer control. Few being:

  • Handles both file:// URIs & File/Directory path as input.
  • Provides a way to distinguish between File, Directory & network URLs.
  • Correctly handles File paths with backward slashes on Windows.
  • Uri.parse & Uri.toFilePath do not handle file:// scheme (with two slashes) correctly on Windows.

License

Copyright ยฉ 2022, Hitesh Kumar Saini <[email protected]>

This project & the work under this repository is governed by MIT license that can be found in the LICENSE file.

uri_parser's People

Contributors

alexmercerind avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.