-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1470 from newrelic/add_link_to_repo_pack_directory
Add link to repo pack directory
- Loading branch information
Showing
5 changed files
with
84 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
module.exports = { | ||
trailingComma: "es5", | ||
trailingComma: 'es5', | ||
printWidth: 80, | ||
tabWidth: 2, | ||
semi: true, | ||
singleQuote: true, | ||
arrowParens: 'always', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import getPackUrl from '../get-pack-url'; | ||
|
||
describe('getPackUrl', () => { | ||
test.each([ | ||
[ | ||
'https://raw.githubusercontent.com/newrelic/newrelic-observability-packs/v0.8.1/packs/apache/logo.svg', | ||
'https://github.com/newrelic/newrelic-observability-packs/tree/main/packs/apache', | ||
], | ||
[ | ||
'https://raw.githubusercontent.com/newrelic/newrelic-observability-packs/v0.8.2/packs/couchbase/logo.svg', | ||
'https://github.com/newrelic/newrelic-observability-packs/tree/main/packs/couchbase', | ||
], | ||
])('given non-falsy logoUrl, %p, returns %p', (firstArg, expectedResult) => { | ||
const packUrl = getPackUrl(firstArg); | ||
|
||
expect(packUrl).toBe(expectedResult); | ||
}); | ||
|
||
test.each([[''], [null], [undefined]])( | ||
'given falsy logoUrl, %p, returns "https://github.com/newrelic/newrelic-observability-packs/tree/main/packs/"', | ||
(firstArg) => { | ||
const packUrl = getPackUrl(firstArg); | ||
|
||
expect(packUrl).toBe( | ||
'https://github.com/newrelic/newrelic-observability-packs/tree/main/packs/' | ||
); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Method to get the URL for a given pack. | ||
* @param {string} logoUrl | ||
* @returns {string} URL for pack. If logoUrl is falsy, URL returned | ||
* will be the parent directory under which all packs live. | ||
*/ | ||
const getPackUrl = (logoUrl) => { | ||
let packUrl = new URL( | ||
'https://github.com/newrelic/newrelic-observability-packs/tree/main/packs/' | ||
); | ||
|
||
if (!logoUrl) { | ||
return packUrl.href; | ||
} | ||
|
||
/** | ||
* logoUrl looks something like: 'https://raw.githubusercontent.com/newrelic/newrelic-observability-packs/v0.8.2/packs/couchbase/logo.svg' | ||
*/ | ||
const [packName] = logoUrl.split('/').slice(-2, -1); | ||
packUrl = new URL(packName, packUrl); | ||
return packUrl.href; | ||
}; | ||
|
||
export default getPackUrl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters