BlobViewer::PackageJson - if private link to homepage
This commit is contained in:
parent
b03789395c
commit
d02059ddf3
3 changed files with 14 additions and 7 deletions
|
@ -21,9 +21,7 @@ module BlobViewer
|
|||
end
|
||||
|
||||
def package_url
|
||||
return nil if private?
|
||||
|
||||
"https://www.npmjs.com/package/#{package_name}"
|
||||
private? ? homepage : npm_url
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -31,5 +29,13 @@ module BlobViewer
|
|||
def private?
|
||||
!!json_data['private']
|
||||
end
|
||||
|
||||
def homepage
|
||||
json_data['homepage']
|
||||
end
|
||||
|
||||
def npm_url
|
||||
"https://www.npmjs.com/package/#{package_name}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
title: Do not generate links for private NPM modules in blob view
|
||||
title: Do not generate NPM links for private NPM modules in blob view
|
||||
merge_request: 16002
|
||||
author: Mario de la Ossa
|
||||
type: added
|
||||
|
|
|
@ -45,7 +45,8 @@ describe BlobViewer::PackageJson do
|
|||
{
|
||||
"name": "module-name",
|
||||
"version": "10.3.1",
|
||||
"private": true
|
||||
"private": true,
|
||||
"homepage": "myawesomepackage.com"
|
||||
}
|
||||
SPEC
|
||||
end
|
||||
|
@ -53,10 +54,10 @@ describe BlobViewer::PackageJson do
|
|||
subject { described_class.new(blob) }
|
||||
|
||||
describe '#package_url' do
|
||||
it 'returns nil' do
|
||||
it 'returns homepage if any' do
|
||||
expect(subject).to receive(:prepare!)
|
||||
|
||||
expect(subject.package_url).to be_nil
|
||||
expect(subject.package_url).to eq('myawesomepackage.com')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue