Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
d02059dd
Commit
d02059dd
authored
Dec 18, 2017
by
Mario de la Ossa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BlobViewer::PackageJson - if private link to homepage
parent
b0378939
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
7 deletions
+14
-7
app/models/blob_viewer/package_json.rb
app/models/blob_viewer/package_json.rb
+9
-3
changelogs/unreleased/36020-private-npm-modules.yml
changelogs/unreleased/36020-private-npm-modules.yml
+1
-1
spec/models/blob_viewer/package_json_spec.rb
spec/models/blob_viewer/package_json_spec.rb
+4
-3
No files found.
app/models/blob_viewer/package_json.rb
View file @
d02059dd
...
@@ -21,9 +21,7 @@ module BlobViewer
...
@@ -21,9 +21,7 @@ module BlobViewer
end
end
def
package_url
def
package_url
return
nil
if
private
?
private
?
?
homepage
:
npm_url
"https://www.npmjs.com/package/
#{
package_name
}
"
end
end
private
private
...
@@ -31,5 +29,13 @@ module BlobViewer
...
@@ -31,5 +29,13 @@ module BlobViewer
def
private?
def
private?
!!
json_data
[
'private'
]
!!
json_data
[
'private'
]
end
end
def
homepage
json_data
[
'homepage'
]
end
def
npm_url
"https://www.npmjs.com/package/
#{
package_name
}
"
end
end
end
end
end
changelogs/unreleased/36020-private-npm-modules.yml
View file @
d02059dd
---
---
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
merge_request
:
16002
author
:
Mario de la Ossa
author
:
Mario de la Ossa
type
:
added
type
:
added
spec/models/blob_viewer/package_json_spec.rb
View file @
d02059dd
...
@@ -45,7 +45,8 @@ describe BlobViewer::PackageJson do
...
@@ -45,7 +45,8 @@ describe BlobViewer::PackageJson do
{
{
"name": "module-name",
"name": "module-name",
"version": "10.3.1",
"version": "10.3.1",
"private": true
"private": true,
"homepage": "myawesomepackage.com"
}
}
SPEC
SPEC
end
end
...
@@ -53,10 +54,10 @@ describe BlobViewer::PackageJson do
...
@@ -53,10 +54,10 @@ describe BlobViewer::PackageJson do
subject
{
described_class
.
new
(
blob
)
}
subject
{
described_class
.
new
(
blob
)
}
describe
'#package_url'
do
describe
'#package_url'
do
it
'returns
nil
'
do
it
'returns
homepage if any
'
do
expect
(
subject
).
to
receive
(
:prepare!
)
expect
(
subject
).
to
receive
(
:prepare!
)
expect
(
subject
.
package_url
).
to
be_nil
expect
(
subject
.
package_url
).
to
eq
(
'myawesomepackage.com'
)
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment