From 350f846ed0345aa266a49da91f655495da3eb19f Mon Sep 17 00:00:00 2001 From: lesterchan Date: Wed, 29 Jul 2009 16:33:24 +0000 Subject: [PATCH] Allow https:// git-svn-id: http://yourls.googlecode.com/svn/trunk@58 12232710-3e20-11de-b438-597f59cd7555 --- includes/functions.php | 8 ++++++-- js/insert.js | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index 2b27c3e..9399b08 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -31,7 +31,11 @@ function yourls_sanitize_string ($in) { // make sure there's one and only one 'http://' at the beginning (prevents omitting or pasting a URL right after the default 'http://') function yourls_sanitize_url($url) { - return preg_replace('#^(http://)+#', 'http://', 'http://'.$url); + if(substr($url, 0, 5) == 'https') { + return preg_replace('#^(https://)+#', 'https://', 'https://'.$url); + } else { + return preg_replace('#^(http://)+#', 'http://', 'http://'.$url); + } } // Make sure an id link is a valid integer (PHP's intval() limits to too small numbers) @@ -153,7 +157,7 @@ function yourls_insert_link_in_db($url, $id, $db) { // Add a new link in the DB, either with custom keyword, or find one function yourls_add_new_link($url, $keyword = '', $db) { - if ( !$url or $url == 'http://' ) { + if ( !$url || $url == 'http://' || $url == 'https://' ) { $return['status'] = 'fail'; $return['message'] = 'Missing URL input'; return $return; diff --git a/js/insert.js b/js/insert.js index 0d27bca..b39e7d4 100644 --- a/js/insert.js +++ b/js/insert.js @@ -15,7 +15,7 @@ $(document).ready(function(){ // Create new link and add to table function add() { var newurl = $("#add-url").val(); - if ( !newurl || newurl == 'http://' ) { + if ( !newurl || newurl == 'http://' || newurl == 'https://' ) { alert('no URL ?'); return; } -- 2.45.0