GithubHelp home page GithubHelp logo

pombredanne / github-short-url-regex Goto Github PK

View Code? Open in Web Editor NEW

This project forked from regexhq/github-short-url-regex

0.0 1.0 0.0 20 KB

Regular expression (Regex) for matching github shorthand (user/repo#branch).

Home Page: http://j.mp/1BNoWzB

License: MIT License

JavaScript 100.00%

github-short-url-regex's Introduction

npm version mit license build status coverage status

Regular expression (Regex) for matching github shorthand (user/repo#branch).

Install

npm i --save github-short-url-regex
npm test

Support

  • github shorthands mochajs/mocha#master
    • where thing after hash (#) represent release, tag or branch
  • npm shorthands gulpjs/[email protected]

githubShortUrlRegex

Find github shorthand url (user/repo#branch)

  • [options] {Object}
    • flags {String} every valid RegExp flag, default undefined
    • exact {Boolean}
  • return {RegExp}

Usage

For more use-cases see the tests

var regex = require('github-short-url-regex');

regex().test('gh tunnckoCore/npmls#master here');
//=> false

regex({flags: 'g'}).test('gh tunnckoCore/npmls#master here');
//=> false

regex({flags: 'g', exact: false}).test('gh tunnckoCore/npmls#master here');
//=> true

regex({flags: 'g', exact: true}).test('gh tunnckoCore/npmls#master here');
//=> false

'gh tunnckoCore/npmls#test here user/repo#branch yea'.match(regex({flags: 'g'}));
//=> null

'gh tunnckoCore/npmls#test here user/repo#branch yea'.match(regex({flags: 'g', exact: false}));
//=> ['tunnckoCore/npmls#test', 'user/repo#branch']

'gh tunnckoCore/npmls#test here user/repo#branch yea'.match(regex({exact: false}))[0];
//=> 'tunnckoCore/npmls#test'

'gh tunnckoCore/npmls#test here user/repo#branch yea'.match(regex({exact: true}));
//=> null

'tunnckoCore/npmls#test'.match(regex({exact: true}))[0];
//=> 'tunnckoCore/npmls#test'
  • regex-cache: Memoize the results of a call to the RegExp constructor, avoiding repetitious runtime compilation of the same string and options, resulting in dramatic speed improvements.
  • utils: Fast, generic JavaScript/node.js utility functions.
  • helper-related: Template helper for generating a list of links to the homepages of related GitHub/npm projects.

Author

Charlike Mike Reagent

License MIT license

Copyright (c) 2014-2015 Charlike Mike Reagent, contributors.
Released under the MIT license.


Powered and automated by docks, March 26, 2015

github-short-url-regex's People

Contributors

greenkeeper[bot] 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.