Skip to content

Commit

Permalink
Merge pull request #47 from bem-site/FEI-901
Browse files Browse the repository at this point in the history
FEI-901 Fix related links to CONTRIBUTING.md library documentation files
  • Loading branch information
tormozz48 committed Oct 28, 2015
2 parents 9dae63b + f0b4ea5 commit 3bf5671
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/tasks/override-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ module.exports = {
buildFullGHUrlToNonDocumentationFile: function (href, node) {
var conditions = node.route.conditions,
blockRegexp = /^\.?\/?(?:\.\.\/)?([\w|-]+)\.blocks\/([\w|-]+)\/?([\w|-]+)?\.(?![md|html|ru\.md|en\.md])/,
licenseRegexp = /^\.?\/?(?:\.\.\/)?LICENSE\.?(txt)?/,
licenseRegexp = /^\.?\/?(?:\.\.\/)?LICENSE\.?(txt)?/i,
contributingRegexp = /^\.?\/?(?:\.\.\/)?CONTRIBUTING\.([md|ru\.md|en\.md])/i,
lib, version, match;

if (!conditions || !conditions.lib || !conditions.version) {
Expand All @@ -148,7 +149,7 @@ module.exports = {
version = conditions.version;


match = href.match(blockRegexp) || href.match(licenseRegexp);
match = href.match(blockRegexp) || href.match(licenseRegexp) || href.match(contributingRegexp);
if (match) {
return [node.ghLibVersionUrl, 'blob', version,
href.replace(/^\.?\/?(?:\.\.\/)?/, '').replace(/^\.?\/?/, '')].join('/');
Expand Down
36 changes: 36 additions & 0 deletions test/tasks/override-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,42 @@ describe('override-links', function () {

assert('./../common.blocks/button/button.js',
'https://github.com/user/repo/my-lib/blob/vx.y.z/common.blocks/button/button.js');

assert('license.txt',
'https://github.com/user/repo/my-lib/blob/vx.y.z/license.txt');

assert('./license.txt',
'https://github.com/user/repo/my-lib/blob/vx.y.z/license.txt');

assert('/license.txt',
'https://github.com/user/repo/my-lib/blob/vx.y.z/license.txt');

assert('LICENSE.txt',
'https://github.com/user/repo/my-lib/blob/vx.y.z/LICENSE.txt');

assert('./LICENSE.txt',
'https://github.com/user/repo/my-lib/blob/vx.y.z/LICENSE.txt');

assert('/LICENSE.txt',
'https://github.com/user/repo/my-lib/blob/vx.y.z/LICENSE.txt');

assert('CONTRIBUTING.md', 'https://github.com/user/repo/my-lib/blob/vx.y.z/CONTRIBUTING.md');

assert('./CONTRIBUTING.md', 'https://github.com/user/repo/my-lib/blob/vx.y.z/CONTRIBUTING.md');

assert('/CONTRIBUTING.md', 'https://github.com/user/repo/my-lib/blob/vx.y.z/CONTRIBUTING.md');

assert('CONTRIBUTING.ru.md', 'https://github.com/user/repo/my-lib/blob/vx.y.z/CONTRIBUTING.ru.md');

assert('./CONTRIBUTING.ru.md', 'https://github.com/user/repo/my-lib/blob/vx.y.z/CONTRIBUTING.ru.md');

assert('/CONTRIBUTING.ru.md', 'https://github.com/user/repo/my-lib/blob/vx.y.z/CONTRIBUTING.ru.md');

assert('CONTRIBUTING.en.md', 'https://github.com/user/repo/my-lib/blob/vx.y.z/CONTRIBUTING.en.md');

assert('./CONTRIBUTING.en.md', 'https://github.com/user/repo/my-lib/blob/vx.y.z/CONTRIBUTING.en.md');

assert('/CONTRIBUTING.en.md', 'https://github.com/user/repo/my-lib/blob/vx.y.z/CONTRIBUTING.en.md');
});

describe('buildSiteUrlsForRelativeBlockLinksOnSameLevel', function () {
Expand Down

0 comments on commit 3bf5671

Please sign in to comment.