This repository has been archived by the owner on Oct 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Showing
8 changed files
with
138 additions
and
34 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
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 |
---|---|---|
@@ -1,11 +1,8 @@ | ||
'use strict' | ||
|
||
function matchExact (myProtocol, senderProtocol, callback) { | ||
if (myProtocol === senderProtocol) { | ||
callback(null, true) | ||
} else { | ||
callback(null, false) | ||
} | ||
const result = myProtocol === senderProtocol | ||
callback(null, result) | ||
} | ||
|
||
module.exports = matchExact |
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,23 @@ | ||
'use strict' | ||
|
||
const semver = require('semver') | ||
|
||
function matchSemver (myProtocol, senderProtocol, callback) { | ||
const mps = myProtocol.split('/') | ||
const sps = senderProtocol.split('/') | ||
const myName = mps[1] | ||
const myVersion = mps[2] | ||
|
||
const senderName = sps[1] | ||
const senderVersion = sps[2] | ||
|
||
if (myName !== senderName) { | ||
return callback(null, false) | ||
} | ||
// does my protocol satisfy the sender? | ||
const valid = semver.satisfies(myVersion, '~' + senderVersion) | ||
|
||
callback(null, valid) | ||
} | ||
|
||
module.exports = matchSemver |
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