Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

issue-regex

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

issue-regex

Regular expression for matching issue references

  • 4.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
218K
decreased by-12.92%
Maintainers
1
Weekly downloads
 
Created
Source

issue-regex

Regular expression for matching issue references

Install

npm install issue-regex

Usage

import issueRegex from 'issue-regex';

'Fixes #143 and avajs/ava#1023'.match(issueRegex());
//=> ['#143', 'avajs/ava#1023']

Organization name, repository name, and issue number are also available individually in capturing groups 1-3, or named groups organization, repository, and issueNumber:

issueRegex().exec('Fixes avajs/ava#1023');
/*
[
	'avajs/ava#1023',
	'avajs',
	'ava',
	'1023',
	index: 6,
	input: 'Fixes avajs/ava#1023',
	groups: {
		organization: 'avajs',
		repository: 'ava',
		issueNumber: '1023'
	}
]
*/

API

issueRegex(options?)

Returns a RegExp for matching issue references.

options

Type: object

additionalPrefix

Support for references like GH-123 can be added manually. Adding a prefix will still match the #-based references:

import issueRegex from 'issue-regex';

issueRegex({additionalPrefix: 'GH-'}).exec('GH-123');
//=> ['GH-123', 'GH-', '123']

'Fixes GH-143 and avajs/ava#1023'.match(issueRegex({additionalPrefix: 'GH-'}));
//=> ['GH-143', 'avajs/ava#1023']

[!NOTE] additionalPrefix is added unescaped to the regex, keep it simple.

Important

If you run the regex against untrusted user input in a server context, you should give it a timeout.

I do not consider ReDoS a valid vulnerability for this package.

  • linkify-issues - Linkify GitHub issue references

Keywords

FAQs

Package last updated on 25 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc