Utilities to work with protocol handlers (like "vscode://") on the web.

Overview

Protocol Handlers

Utilities to work with protocol handlers on the web.

Why?

While the Navigator API provides methods to .registerProtocolHandler() and .unregisterProtocolHandler(), there's no way to check if a given protocol has a handler. Instead, when trying to open a URL with an unsupported protocol the browser will throw an error that you cannot handle by any normal means (can be handled only in Firefox).

This package fills in the gap and provides API to work with protocol handlers.

Install

npm install protocol-handlers

API

openUrl

Returns a promise that resolves if the given URL has successfuly opened (has a registered handler for its protocol) or rejects if it doesn't have a registered handler.

import { openUrl, UnsupportedProtocolError } from 'protocol-handlers'

// For example, try to open a Visual Studio Code Insiders URI.
// If that application is not installed, handle the rejection.
openUrl('vscode-insiders://resource').catch((error) => {
  if (error instanceof UnsupportedProtocolError) {
    console.log('The "%s" protocol is not supported!', error.protocol)
  }
})

Options

timeout: number

A custom timeout duration.

openUrl('my-app://resource', {
  // Wait for 2s for the navigation modal to appear
  // before rejecting this Promise.
  timeout: 2000,
})
You might also like...

Todo List is a simple web-based application that gives users the ability to organize their work and life daily tasks. Built with JavaScript, HTML/CSS.

Javascript Project Todo List Using Javascript to create a simple Todo List project. Populating the todo list and then removing from the list. Built Wi

Sep 28, 2022

TypeScript isomorphic library to make work with Telegram Web Apps init data easier.

Telegram Web Apps Init Data TypeScript isomorphic library to make work with Telegram Web Apps init data easier. Feel free to use it in browser and Nod

Oct 7, 2022

Leader Board is a simple project based on JavaScript programing language. The purpose of this project is to work with APIs and ASYNC & AWAIT methods. I have used vanilla JavaScript with web pack to implement this project

Leader Board is a simple project based on JavaScript programing language. The purpose of this project is to work with APIs and ASYNC & AWAIT methods. I have used vanilla JavaScript with web pack to implement this project

Leader Board - JavaScript Project Table of contents Overview The challenge Screenshot Links Project Setup commands My process Built with What I learne

Oct 21, 2022

Library for interacting with RMM protocol through ethers.js.

🍄 rmm-ethers Easily connect and transact with RMM protocol. 🧩 Features 🌲 Deploy RMM protocol ⚡️ Easily connect to an RMM deployment 🌊 Create RMM p

Nov 13, 2022

Send data to Google Analytics with Measurement Protocol.

Send data to Google Analytics with Measurement Protocol.

Strapi Measurement Protocol Send data to Google Analytics with Measurement Protocol. Table of Contents 🚦 Current Status ✨ Features 🖐 Installation 🚚

Sep 16, 2022

A simple implementation example (framework) of Deso Protocol's Smart Services.

This project serves as a simple implementation example (framework) of Deso Protocol's Smart Services. This framework comes with out-of-the-box SSL, MongoDB, dev/stage/prod environments, and modularity.

Sep 22, 2022

A TypeScript library for OPAQUE Asymmetric Password-Authenticated Key Exchange Protocol

A TypeScript library for OPAQUE Asymmetric Password-Authenticated Key Exchange Protocol

opaque-ts This is a Typescript library for the Asymmetric Password-Authenticated Key Exchange (OPAQUE) protocol. Use Available at: @cloudflare/opaque-

Dec 30, 2022

A fast Protocol 6 Agar.io client for private servers

A fast Protocol 6 Agar.io client for private servers

Cigar3 A fast Protocol 6 Agar.io client for private servers Getting started. After installing nodejs, run npm install and npm run cigar3 in a terminal

Mar 6, 2022

Perpetual Protocol Curie (v2) core contracts

Perpetual Protocol Curie (v2) core contracts

Dec 15, 2022
Releases(v0.1.3)
Owner
Artem Zakharchenko
Teaching people that testing can be useful and fun.
Artem Zakharchenko
A work-in-progress HTML sanitizer that strives for: performance like window.Sanitizer, readiness like DOMPurify, and ability to run in a WebWorker like neither of those.

Amuchina A work-in-progress HTML sanitizer that strives for: performance like window.Sanitizer, readiness like DOMPurify, and ability to run in a WebW

Fabio Spampinato 9 Sep 17, 2022
VSCode Extension & utilities for exploring TypeScript type information

ts-type-explorer VSCode Extension & utilities to explore type information in TypeScript projects. Installation Check out the releases page to download

Max Stoumen 6 Nov 20, 2022
Manage you go.work easily in vscode!🥯

vscode-go-work-manager vscode-go-work-manager is a go.work manager uses workman Features toggle on/off your go modules from go.work file easily. Requi

Dash Wong 5 Sep 8, 2022
A JavaScript Library To Make Your Work Work Easier/Faster

Functionalty.js (beta) About ✍️ This Is A JavaScript Library To Make Your Work Easier/Faster, You Can See Functionalty.js Website From Here Project Cr

Ali-Eldeba 16 Aug 30, 2022
A JavaScript Library To Make Your Work Work Easier/Faster

Functionality.js (beta) About ✍️ This Is A JavaScript Library To Make Your Work Easier/Faster, You Can See Functionalty.js Website From Here Project C

Ali-Eldeba 9 May 25, 2022
A JavaScript Library To Make Your Work Work Easier/Faster

Functionality.js About ✍️ This Is A JavaScript Library To Make Your Work Easier/Faster, You Can See Functionalty.js Website From Here Project Created

functionality 16 Jun 23, 2022
✒️ A VSCode-like command palette plugin for inkdrop

inkdrop command palette A VSCode-like command palette for Inkdrop. (Invoke using Ctrl+K) https://my.inkdrop.app/plugins/command-palette ?? You may nee

Jariel Que 11 Nov 1, 2022
Collection of SEO utilities like sitemap, robots.txt, etc. for a Remix Application

Remix SEO Collection of SEO utilities like sitemap, robots.txt, etc. for a Remix Features Generate Sitemap Generate Robots.txt Installation To use it,

Balavishnu V J 128 Dec 21, 2022
A complete application tutorial to show how to implement the Web Socket protocol using only Node.js builtin modules

Web Socket application using only Node.js built-in modules About Welcome, this repo is part of my youtube video about Building a complete application

Erick Wendel 35 Dec 19, 2022
Optimized dracula theme vscode extension for flutter, web, electron and golang development.

Optimized Dracula Theme A color theme inspired by dracula color theme. This color theme is not based on dracula color theme. The color styles are simi

wuchuran 1 Jul 11, 2022