npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

remark-application-links

v1.0.0

Published

![logo](./.github/logo.png)

Downloads

6

Readme

logo

remark-application-links

You want to allow your users to directly link deeply into their favorite applications like Notion or Mail. Per default remark only supports a handful of valid protocols when parsing links from text which makes this impossible. With the remark-application-links plugin you can support all the schemes and specify a block list of potentially dangerous ones.

Turn

Here's a link to my notion: notion://notion.so/user/123

into

<p>
    Here's a link to my notion:
    <a href="notion://notion.so/user/123">notion://notion.so/user/123</a>
</p>

Make sure you understand the security implications before using this plugin: Security

Heavily inspired by remark-linkify-regex but different enough to justify a separate plugin.

Bootstrapped and built with tsdx.

Installation

Use npm or yarn to install:

npm install @doist/remark-application-links
# or
yarn add @doist/remark-application-links

Usage

This plugin exposes a function which you need to call with the blocked URL schemes (or with nothing to accept the default ones).

remark().use(remarkApplicationLinksPlugin())
// or with custom schemes
remark().use(remarkApplicationLinksPlugin(['javascript', 'notion']))

Security

Since this plugin is using a block list of URL schemes instead of explictly allowing explicit ones it potentially opens up your application for attackers. The general stance in the security community is that a complete block list is hard (read: impossible) to achieve. If you want to be on the safe side it's better to rely on an explicit allow list of supported URL schemes.

Per default we're blocking these url schemes:

const blockedUrlSchemes = ['data', 'jar', 'java', 'javascript', 'vbscript', 'view-source']

In general it's recommended to not only rely on your parser to prevent inline script executions but apply a Content-Security Policy (CSP) on your page as reliable catch-all.

You're advised to thoroughly test your use cases to not open your users up to cross-site scripting (XSS) attacks. You might find additional tools like rehype-sanitize helpful.

Markdown links and react-markdown

This plugin will transform this text:

[link](<javascript:alert(1)>)

into

<p><a href="javascript:alert(1)">link</a></p>

Which is dangerous as it would execute JavaScript. If you allow users to enter the text this will open you up to cross-site scripting (XSS) attacks. As mentioned above a strong CSP will protect you from this and not allow the JavaScript to execute.

This plugin can be used in combination with react-markdown. In order to prevent the example above being parsed as a link you need to supply the transformLinkUri prop.

Changelog

We're maintaining a changelog in this repository. Our versioning follows semantic versioning.

Contributing

Contributions are welcome. Check our contributing guide.

License

This project is distributed under the MIT License.