Skip to content

Commit

Permalink
Fix URLs as dependencies in package.json (OctoLinker#793)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanbuck authored Jan 26, 2020
1 parent 81cf2bf commit 0299944
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 10 deletions.
8 changes: 7 additions & 1 deletion e2e/fixtures/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
},
"devDependencies": {
"//": "@OctoLinkerResolve(https://github.com/jashkenas/underscore)",
"underscore": "1.2.3"
"underscore": "1.2.3",
"//": "@OctoLinkerResolve(https://github.com/expressjs/express)",
"express": "expressjs/express",
"//": "@OctoLinkerResolve(https://github.com/mochajs/mocha/tree/v7.0.0)",
"mocha": "mochajs/mocha#v7.0.0",
"//": "@OctoLinkerResolve(https://github.com/angular/angular)",
"angular": "[email protected]:angular/angular.git"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,19 @@ Array [
},
]
`;

exports[`get-position returns an empty array when capture group is empty 1`] = `
Array [
Object {
"endPos": 3,
"endPosInBlob": 3,
"lineNumber": 1,
"startPos": 0,
"startPosInBlob": 0,
"values": Array [
"foo",
"bar",
],
},
]
`;
3 changes: 3 additions & 0 deletions packages/helper-insert-link/__tests__/get-position.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ describe('get-position', () => {
test('returns an empty array when capture group is empty', () => {
expect(getPosition('foo:bar', /foo:([0-9])?/g)).toStrictEqual([]);
});
test('returns an empty array when capture group is empty', () => {
expect(getPosition('foo:bar', /(foo):(bar)/g)).toMatchSnapshot();
});
});
2 changes: 1 addition & 1 deletion packages/helper-insert-link/get-position.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function(blobString, regex) {
endPosInBlob,
startPos,
endPos,
values: [matchValueStriped],
values: [matchValueStriped, ...match.slice(2)],
};
})
.filter(Boolean);
Expand Down
1 change: 0 additions & 1 deletion packages/helper-insert-link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ export default function(blob, regex, plugin, meta = {}) {
endPos = endPosInBlob;
}

// TODO push link el into matches along with the urls prop
const retEl = injectUrl(el, values[0], startPos, endPos);
if (retEl) {
matches.push({
Expand Down
12 changes: 6 additions & 6 deletions packages/helper-regex-builder/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import { jsonRegExValue, jsonRegExKeyValue } from '../index';

describe('helper-regex-builder', () => {
it('jsonRegExValue', () => {
expect(jsonRegExValue('foo', 'bar')).toEqual(/"foo"\s*:\s*("bar")/g);
expect(jsonRegExValue('foo', 'bar', false)).toEqual(/"foo"\s*:\s*("bar")/g);
expect(jsonRegExValue('foo', 'bar', true)).toEqual(/"foo"\s*:\s*("bar")/g);
expect(jsonRegExValue('foo', 'bar')).toEqual(/"foo"\s*:\s*"(bar)"/g);
expect(jsonRegExValue('foo', 'bar', false)).toEqual(/"foo"\s*:\s*"(bar)"/g);
expect(jsonRegExValue('foo', 'bar', true)).toEqual(/"foo"\s*:\s*"(bar)"/g);
});

it('jsonRegExKeyValue', () => {
expect(jsonRegExKeyValue('foo', 'bar')).toEqual(/("foo")\s*:\s*("bar")/g);
expect(jsonRegExKeyValue('foo', 'bar')).toEqual(/("foo")\s*:\s*"(bar)"/g);
expect(jsonRegExKeyValue('foo', 'bar', false)).toEqual(
/("foo")\s*:\s*("bar")/g,
/("foo")\s*:\s*"(bar)"/g,
);
expect(jsonRegExKeyValue('foo', 'bar', true)).toEqual(
/("foo")\s*:\s*("bar")/g,
/("foo")\s*:\s*"(bar)"/g,
);
});
});
2 changes: 1 addition & 1 deletion packages/helper-regex-builder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function regexBuilder(key, value, groupKey) {
}

const regexValue = escapeRegexString(value);
const valueField = `("${regexValue}")`;
const valueField = `"(${regexValue})"`;
return new RegExp(`${keyField}\\s*:\\s*${valueField}`, 'g');
}

Expand Down

0 comments on commit 0299944

Please sign in to comment.