-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stefan Buck
committed
Oct 1, 2020
1 parent
2758891
commit f3616ea
Showing
6 changed files
with
86 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -43,6 +43,7 @@ Type must be one of: | |
- `java` | ||
- `go` | ||
- `pub` | ||
- `cran` | ||
- `ping` | ||
|
||
Response: | ||
|
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
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,15 @@ | ||
function prioritiesHost(host, urls = []) { | ||
let insertIndex = 0; | ||
return urls.reduce((memo, url) => { | ||
if (url.includes(host)) { | ||
memo.splice(insertIndex++, 0, url); // eslint-disable-line no-plusplus | ||
} else { | ||
memo.push(url); | ||
} | ||
return memo; | ||
}, []); | ||
} | ||
|
||
module.exports = { | ||
prioritiesHost, | ||
}; |
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,39 @@ | ||
const { prioritiesHost } = require('./url.js'); | ||
|
||
const inputUrls = [ | ||
'https://foo.com', | ||
'https://github.com/foo', | ||
'https://bar.com', | ||
'https://github.com/bar', | ||
]; | ||
|
||
describe('url', () => { | ||
describe('prioritiesHost', () => { | ||
it('priorities github.com', () => { | ||
expect(prioritiesHost('github.com', inputUrls)).toStrictEqual([ | ||
'https://github.com/foo', | ||
'https://github.com/bar', | ||
'https://foo.com', | ||
'https://bar.com', | ||
]); | ||
}); | ||
|
||
it('priorities foo.com', () => { | ||
expect(prioritiesHost('foo.com', inputUrls)).toStrictEqual([ | ||
'https://foo.com', | ||
'https://github.com/foo', | ||
'https://bar.com', | ||
'https://github.com/bar', | ||
]); | ||
}); | ||
|
||
it('priorities bar.com', () => { | ||
expect(prioritiesHost('bar.com', inputUrls)).toStrictEqual([ | ||
'https://bar.com', | ||
'https://foo.com', | ||
'https://github.com/foo', | ||
'https://github.com/bar', | ||
]); | ||
}); | ||
}); | ||
}); |