Add slash to URL from notification button

This commit is contained in:
varjolintu 2018-08-02 16:51:00 +03:00 committed by Jonathan White
parent 0ea9fb20e5
commit afe66d3656
4 changed files with 15 additions and 8 deletions

View file

@ -90,4 +90,10 @@ var matchPatternToRegExp = function(pattern) {
var siteMatch = function(site, url) {
const rx = matchPatternToRegExp(site);
return url.match(rx);
};
// Checks if URL has only scheme and host without the last / char.
var slashNeededForUrl = function(pattern) {
const matchPattern = new RegExp(`^${schemeSegment}://${hostSegment}$`);
return matchPattern.exec(pattern);
};

View file

@ -2053,9 +2053,13 @@ cip.ignoreSite = function(sites) {
return;
}
const site = sites[0];
let site = sites[0];
cip.initializeSitePreferences();
if (slashNeededForUrl(site)) {
site += '/';
}
// Check if the site already exists
let siteExists = false;
for (const existingSite of cip.settings['sitePreferences']) {

View file

@ -314,7 +314,7 @@ options.initSitePreferences = function() {
trClone.removeClass('clone');
// Fills the last / char if needed. This ensures the compatibility with Match Patterns
if (options.slashNeededForUrl(value)) {
if (slashNeededForUrl(value)) {
value += '/';
}
@ -396,9 +396,3 @@ options.initAbout = function() {
$('#default-pass-shortcut').show();
}
};
// Checks if URL has only scheme and host without the last / char.
options.slashNeededForUrl = function(pattern) {
const matchPattern = new RegExp(`^${schemeSegment}://${hostSegment}$`);
return matchPattern.exec(pattern);
};

View file

@ -4,6 +4,9 @@ body {
background-color: #eee;
font-size: 15px;
padding: 8px;
min-width: 440px;
max-width: 460px;
width: auto;
}
.container {
min-width: 440px;