<commit_before><?php

require('config.php');

header('Content-Type: text/plain;charset=UTF-8');

$url = urldecode(trim($_GET['url']));

if (in_array($url, array('', 'about:blank', 'undefined', 'http://localhost/'))) {
 die('Enter a URL.');
}

function nextLetter(&$str) {
 $str = ('z' === $str ? 'a' : ++$str);
}

function getNextShortURL($s) {
 $a = str_split($s);
 $c = count($a);
 if (preg_match('/^z*$/', $s)) { // string consists entirely of `z`
  return str_repeat('a', $c + 1);
 }
 while ('z' === $a[--$c]) {
  nextLetter($a[$c]);
 }
 nextLetter($a[$c]);
 return implode($a);
}<commit_msg>Show error message when no `url` parameter was passed to shorten.php.<commit_after><?php

require('config.php');

header('Content-Type: text/plain;charset=UTF-8');

$url = isset($_GET['url']) ? urldecode(trim($_GET['url'])) : '';

if (in_array($url, array('', 'about:blank', 'undefined', 'http://localhost/'))) {
 die('Enter a URL.');
}

function nextLetter(&$str) {
 $str = ('z' === $str ? 'a' : ++$str);
}

function getNextShortURL($s) {
 $a = str_split($s);
 $c = count($a);
 if (preg_match('/^z*$/', $s)) { // string consists entirely of `z`
  return str_repeat('a', $c + 1);
 }
 while ('z' === $a[--$c]) {
  nextLetter($a[$c]);
 }
 nextLetter($a[$c]);
 return implode($a);
}
{'fraction_non_alphanumeric': 0.27372549019607845, 'fraction_numerical': 0.003137254901960784, 'mean_word_length': 4.880184331797235, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6831819', 'n_tokens_mistral': 500, 'n_tokens_neox': 488, 'n_words': 105}