[polari] utils: Match any URI scheme
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] utils: Match any URI scheme
- Date: Sun, 9 Oct 2016 16:16:04 +0000 (UTC)
commit 094d7d1cc119374a2e0c01982c7015d4253375a5
Author: Florian Müllner <fmuellner gnome org>
Date: Sat Feb 20 17:05:40 2016 +0100
utils: Match any URI scheme
Since commit 651c71fed54, we don't use a fixed list of URI schemes
to linkify, but query the system for the list of supported schemes.
Unfortunately this requires access to the list of all installed
applications, which we don't have when running in a flatpak sandbox.
We could easily fix the 99% case by always adding http(s) to the
list, but as unsupported schemes should be extremely rare in the
wild, we can just live with the handful of false positives and
linkify any URI scheme.
https://bugzilla.gnome.org/show_bug.cgi?id=772655
src/utils.js | 21 +--------------------
1 files changed, 1 insertions(+), 20 deletions(-)
---
diff --git a/src/utils.js b/src/utils.js
index 66b11f5..97c680b 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -53,13 +53,12 @@ const IMGUR_CLIENT_ID = '4109e59177ec95e';
const _balancedParens = '\\((?:[^\\s()<>]+|(?:\\(?:[^\\s()<>]+\\)))*\\)';
const _leadingJunk = '[\\s`(\\[{\'\\"<\u00AB\u201C\u2018]';
const _notTrailingJunk = '[^\\s`!()\\[\\]{};:\'\\".,<>?\u00AB\u00BB\u201C\u201D\u2018\u2019]';
-const _uriList = getURISchemes();
const _urlRegexp = new RegExp(
'(^|' + _leadingJunk + ')' +
'(' +
'(?:' +
- '(?:' + _uriList.join('|') + '):' + // scheme:
+ '(?:[a-z]+):' + // scheme:
'|' +
'www\\d{0,3}[.]' + // www.
'|' +
@@ -79,24 +78,6 @@ const _urlRegexp = new RegExp(
const _channelRegexp = new RegExp('(^| )#([\\w\\+\\.-]+)','g');
-function getURISchemes() {
- let apps = Gio.AppInfo.get_all();
- let prefix = 'x-scheme-handler/';
- let schemes = [];
-
- apps.forEach(function(app) {
- let types = app.get_supported_types();
- if (!types)
- return;
-
- types.forEach(function(type) {
- if (type.startsWith(prefix))
- schemes.push(type.replace(prefix, ''));
- });
- });
- return schemes;
-}
-
function getTpEventTime() {
let time = Gtk.get_current_event_time ();
if (time == 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]