diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 88d47aec..6de8d60e 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -42,7 +42,7 @@ class AppServiceProvider extends ServiceProvider $tag = Tag::firstOrCreate(['tag' => $tag]); $tagsToAdd[] = $tag->id; } - if (count($tagsToAdd > 0)) { + if (count($tagsToAdd) > 0) { $note->tags()->attach($tagsToAdd); } }); diff --git a/helpers.php b/helpers.php index d70efc56..aeec0625 100644 --- a/helpers.php +++ b/helpers.php @@ -16,6 +16,7 @@ if (! function_exists('normalize_url')) { $newUrl = ''; $url = parse_url($url); $defaultSchemes = ['http' => 80, 'https' => 443]; + if (isset($url['scheme'])) { $url['scheme'] = strtolower($url['scheme']); // Strip scheme default ports @@ -27,10 +28,12 @@ if (! function_exists('normalize_url')) { } $newUrl .= "{$url['scheme']}://"; } + if (isset($url['host'])) { $url['host'] = mb_strtolower($url['host']); $newUrl .= $url['host']; } + if (isset($url['port'])) { $newUrl .= ":{$url['port']}"; } @@ -63,10 +66,14 @@ if (! function_exists('normalize_url')) { } $url['path'] = preg_replace_callback( array_map( - create_function('$str', 'return "/%" . strtoupper($str) . "/x";'), + function ($str) { + return "/%" . strtoupper($str) . "/x"; + }, $u ), - create_function('$matches', 'return chr(hexdec($matches[0]));'), + function ($matches) { + return chr(hexdec($matches[0])); + }, $url['path'] ); // Remove directory index