From 29c037e3c5601731b7ec0e9555bd09fe5531bd05 Mon Sep 17 00:00:00 2001 From: Jacob Evan Shreve Date: Sun, 19 May 2019 15:24:00 -0400 Subject: [PATCH] Allow URLs to end with trailing slash --- CHANGELOG.md | 1 + alacritty_terminal/src/url.rs | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b902ebba..1e0d9fdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Selections not automatically expanding across double-width characters - On macOS, automatic graphics switching has been enabled again - Text getting recognized as URLs without slashes separating the scheme +- URL parser dropping trailing slashes from valid URLs ### Removed diff --git a/alacritty_terminal/src/url.rs b/alacritty_terminal/src/url.rs index 7f47e12d..b10f2421 100644 --- a/alacritty_terminal/src/url.rs +++ b/alacritty_terminal/src/url.rs @@ -18,7 +18,7 @@ use crate::term::cell::{Cell, Flags}; // See https://tools.ietf.org/html/rfc3987#page-13 const URL_SEPARATOR_CHARS: [char; 10] = ['<', '>', '"', ' ', '{', '}', '|', '\\', '^', '`']; -const URL_DENY_END_CHARS: [char; 8] = ['.', ',', ';', ':', '?', '!', '/', '(']; +const URL_DENY_END_CHARS: [char; 7] = ['.', ',', ';', ':', '?', '!', '(']; const URL_SCHEMES: [&str; 8] = ["http://", "https://", "mailto:", "news:", "file://", "git://", "ssh://", "ftp://"]; @@ -245,11 +245,11 @@ mod tests { url_test(")https://example.org(", "https://example.org"); url_test("https://example.org)", "https://example.org"); url_test("https://example.org(", "https://example.org"); - url_test("(https://one.org/)(https://two.org/)", "https://one.org"); + url_test("(https://one.org/)(https://two.org/)", "https://one.org/"); url_test("https://[2001:db8:a0b:12f0::1]:80", "https://[2001:db8:a0b:12f0::1]:80"); url_test("([(https://example.org/test(ing))])", "https://example.org/test(ing)"); - url_test("https://example.org/]()", "https://example.org"); + url_test("https://example.org/]()", "https://example.org/"); url_test("[https://example.org]", "https://example.org"); url_test("'https://example.org/test'ing'''", "https://example.org/test'ing'"); @@ -276,6 +276,7 @@ mod tests { url_test("https://example.org/test?ing", "https://example.org/test?ing"); url_test("https://example.org.,;:)'!/?", "https://example.org"); url_test("https://example.org'.", "https://example.org"); + url_test("https://example.org/test/?;:", "https://example.org/test/"); } #[test]