Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions public/js/controllers/formController.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ controllers.controller('FormController', ['$scope', '$http', '$modal', '$q', 'ta
$scope.getSuggestedData = function(link) {
var urlRegEx = /(http|https|ftp):\/\/[-a-zA-Z0-9@:%_\+.~#?&\/\/=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?$&\/\/=]*)?/gi;

//No error message if no link
if(link.length === 0){
$scope.suggestedData = '';
return;
}

//If entered data doesn't match the URL regex, then return error data, and don't actually make the AJAX request.
if (!urlRegEx.test(link)) {
var badURL = {warning: "Snap! That link came back with nothing. How about pasting it in?", tags: []};
Expand Down