Giter Site home page Giter Site logo

marijns95 / webbrowser-rs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from amodm/webbrowser-rs

0.0 1.0 0.0 254 KB

Rust library to open URLs in the web browsers available on a platform

License: Apache License 2.0

Shell 0.47% C 0.28% Rust 97.51% Swift 0.92% HTML 0.82%

webbrowser-rs's Introduction

webbrowser

Current Crates.io Version Crates.io Downloads License

Linux Build Windows Build MacOS Build iOS Build Android Build WASM Build

Rust library to open URLs and local files in the web browsers available on a platform, with guarantees of Consistent Behaviour.

Inspired by the webbrowser python library

Documentation

Examples

use webbrowser;

if webbrowser::open("http://github.com").is_ok() {
    // ...
}

Platform Support

Platform Supported Browsers Test status
macos default + others
windows default only
linux/wsl/*bsd default only (respects $BROWSER env var, so can be used with other browsers)
android default only
ios default only
wasm default only
haiku ✅ (experimental) default only

Consistent Behaviour

webbrowser defines consistent behaviour on all platforms as follows:

  • Browser guarantee - This library guarantees that the browser is opened, even for local files - the only crate to make such guarantees at the time of this writing. Alternative libraries rely on existing system commands, which may lead to an editor being opened (instead of the browser) for local html files, leading to an inconsistent behaviour for users.
  • Non-Blocking for GUI based browsers (e.g. Firefox, Chrome etc.), while Blocking for text based browser (e.g. lynx etc.)
  • Suppressed output by default for GUI based browsers, so that their stdout/stderr don't pollute the main program's output. This can be overridden by webbrowser::open_browser_with_options.

Crate Features

webbrowser optionally allows the following features to be configured:

  • hardened - this disables handling of non-http(s) urls (e.g. file:///) as a hard security precaution
  • disable-wsl - this disables WSL file implementation (http still works)
  • wasm-console - this enables logging to wasm console (valid only on wasm platform)

Looking to contribute?

PRs invited for

  • Bugs
  • Supporting non-default browser invocation on any platform

Important note (while testing):

  • This library requires availability of browsers and a graphical environment during runtime
  • cargo test will actually open the browser locally

When contributing, please note that your work will be dual licensed as MIT + Apache-2.0 (see below).

License

SPDX-License-Identifier: Apache-2.0 OR MIT

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

webbrowser-rs's People

Contributors

amodm avatar themadprofessor avatar qryxip avatar erichdongubler avatar hakolao avatar hrydgard avatar hosseind2017 avatar azorlogh avatar hrkfdn avatar nachtalb avatar n0toose avatar rib avatar vzout avatar tokusumi avatar yazgoo avatar

Watchers

 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.