Not secure urls are transformed to https

This commit is contained in:
ismaelpadilla 2020-02-02 20:45:40 -03:00
parent ab1ca48fca
commit f7fe26235a
3 changed files with 6 additions and 2 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "reddit-slideshow", "name": "reddit-slideshow",
"version": "0.1.1", "version": "0.1.2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "reddit-slideshow", "name": "reddit-slideshow",
"version": "0.1.1", "version": "0.1.2",
"private": true, "private": true,
"dependencies": { "dependencies": {
"axios": "^0.19.0", "axios": "^0.19.0",

View File

@ -137,8 +137,12 @@ class App extends Component {
/** /**
* Only keep valid urls and extensions. * Only keep valid urls and extensions.
* Returns a valid url or null if url parameter isn't valid. * Returns a valid url or null if url parameter isn't valid.
* Not secure urls are transformed to https.
*/ */
filterUrl = (url) => { filterUrl = (url) => {
// Transform http to https
url = url.replace("http://", "https://");
const domain = url.match(/:\/\/(.+)\//)[1]; const domain = url.match(/:\/\/(.+)\//)[1];
const extPattern = /\.[0-9a-z]+$/i; const extPattern = /\.[0-9a-z]+$/i;
const match = url.match(extPattern); const match = url.match(extPattern);