Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"ecmaFeatures": {
"modules": true
},
"env": {
"env": {
"node": true,
"es6": true,
"mocha": true
Expand Down
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
language: node_js
node_js:
- "6"
- 8
- 10
- 12
cache:
- node_modules
install:
- npm install
- npm install -g eslint
- npm install -g codecov
script:
- eslint .
- npm run lint
- istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec
- codecov

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ query
.get() // /[a-z]{3}[0-9]*$/g
```

Required Node 6.0+ for the ES6 support, Or you can use [Babel](http://babeljs.io/) to support Node below 6.0.
Required Node 8.0+ for the ES6 support, Or you can use [Babel](http://babeljs.io/) to support Node below 6.0.

Using [Webpack](http://webpack.github.io) and [babel-loader](https://github.com/babel/babel-loader) to pack it if want to use in browsers.

Expand Down
5 changes: 4 additions & 1 deletion lib/Builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class Builder {
noDigit() {
this._validateAndAddMethodType(METHOD_TYPE_CHARACTER, METHOD_TYPES_ALLOWED_FOR_CHARACTERS)

return this.add(`[^0-9]`)
return this.add('[^0-9]')
}

/**
Expand Down Expand Up @@ -761,6 +761,9 @@ class Builder {
_mapCaptureIndexToName(result) {
const names = this._captureNames

// No match
if (!result) {return null}

return Array.prototype.reduce.call(result.slice(1), (result, current, index) => {
if (names[index]) {
result[names[index]] = current || ''
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "srl",
"version": "0.2.2",
"version": "0.2.3",
"description": "Simple Regex Language",
"main": "lib/SRL.js",
"scripts": {
"test": "mocha",
"lint": "eslint lib --fix",
"coverage": "istanbul cover _mocha"
},
"repository": {
Expand All @@ -30,6 +31,7 @@
},
"homepage": "https://simple-regex.com",
"devDependencies": {
"eslint": "^6.8.0",
"istanbul": "^0.4.5",
"mocha": "^3.0.2",
"mocha-lcov-reporter": "^1.2.0"
Expand Down
16 changes: 16 additions & 0 deletions test/issue-17-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict'

const assert = require('assert')
const SRL = require('../')

describe('Fix issue 17', () => {
it('Capture group name assignment fails', () => {
assert.doesNotThrow(() => {
const query = new SRL('capture (literally "TEST") as test')
const match = query.getMatch('WORD NOT HERE')
assert.equal(match, null)
}, TypeError)
})
})