Change code structure

This commit is contained in:
Yarmo Mackenbach 2020-10-24 20:33:34 +02:00
parent 568f62a7cd
commit 33a2a7804a

View file

@ -13,25 +13,25 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
exports.list = [ const list = [
'dns', 'dns',
'xmpp', 'xmpp',
'twitter', 'twitter',
'hackernews', 'hackernews',
] ]
exports.data = { const data = {
dns: require('./serviceproviders/dns'), dns: require('./serviceproviders/dns'),
xmpp: require('./serviceproviders/xmpp'), xmpp: require('./serviceproviders/xmpp'),
twitter: require('./serviceproviders/twitter'), twitter: require('./serviceproviders/twitter'),
hackernews: require('./serviceproviders/hackernews'), hackernews: require('./serviceproviders/hackernews'),
} }
exports.match = (uri) => { const match = (uri) => {
let matches = [], sp let matches = [], sp
serviceprovidersList.forEach((spName, i) => { list.forEach((spName, i) => {
sp = serviceproviders[spName] sp = data[spName]
if (sp.reURI.test(uri)) { if (sp.reURI.test(uri)) {
matches.push(sp.processURI(uri)) matches.push(sp.processURI(uri))
} }
@ -39,3 +39,7 @@ exports.match = (uri) => {
return matches return matches
} }
exports.list = list
exports.data = data
exports.match = match