Skip to content

Commit 259eb8f

Browse files
Merge pull request #223 from learnsoftwaredevelopment/resolved-video-host-whitelist-bug
Resolved a bug where previously video host with subdomain `www.` was not part of whitelist
2 parents e1aa8a0 + 5023ac7 commit 259eb8f

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

models/software.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const mongoose = require('mongoose');
22
const { isURL } = require('validator');
33
const uniqueValidator = require('mongoose-unique-validator');
4+
const { ALLOWED_VIDEO_HOST_WHITELIST } = require('../utils/config');
45

56
const softwareSchema = new mongoose.Schema(
67
{
@@ -101,7 +102,7 @@ const softwareSchema = new mongoose.Schema(
101102
if (value) {
102103
return isURL(value, {
103104
protocols: ['http', 'https'],
104-
host_whitelist: ['youtube.com', 'vimeo.com'],
105+
host_whitelist: ALLOWED_VIDEO_HOST_WHITELIST,
105106
});
106107
}
107108
return true;

requests/api/auth/post_auth_login.rest

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ POST http://localhost:3001/api/auth/login
22
Content-Type: application/json
33

44
{
5-
"email": "sample@example.com",
6-
"password": "SamplePassword"
5+
"email": "lecamiv920@activesniper.com",
6+
"password": "password"
77
}

utils/config.js

+7
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,18 @@ const MONGODB_URI = NODE_ENVIRONMENT === 'test'
1111

1212
const { FIREBASE_CLIENT_API_KEY } = process.env;
1313
const ALLOWED_USERNAME_REGEX = '^[a-z0-9_]+$';
14+
const ALLOWED_VIDEO_HOST_WHITELIST = [
15+
'youtube.com',
16+
'vimeo.com',
17+
'www.youtube.com',
18+
'www.vimeo.com',
19+
];
1420

1521
module.exports = {
1622
PORT,
1723
NODE_ENVIRONMENT,
1824
MONGODB_URI,
1925
ALLOWED_USERNAME_REGEX,
2026
FIREBASE_CLIENT_API_KEY,
27+
ALLOWED_VIDEO_HOST_WHITELIST
2128
};

0 commit comments

Comments
 (0)