<commit_before>/**
 * @ngdoc service
 * @name settingsService
 *
 * @module flynnBookScannerApp
 *
 * @description
 * Provides access to the book inventory. Used PouchDB as backend.
 */
app.service('settingsService', ['$rootScope', '$log', '$http', 'localStorageService', 'APP_CONFIG',
    function($rootScope, $log, $http, localStorage, APP_CONFIG) {
        'use strict';

        function saveSettings(pConfig) {
            localStorage.remove('flynn_app.settings');
            var config = pConfig;
            if (!config.appConfig || APP_CONFIG.update) {
                config.appConfig = APP_CONFIG;
            }
            localStorage.add('flynn_app.settings', config);
        }

        function loadSettings() {
            $log.debug('Loading settings from local storage');
            var settings = localStorage.get('flynn_app.settings');
            if (settings) {
                // validate settings
                if (settings.profiles && settings.profiles[settings.activeProfileID]) {
                    var activeProfile = settings.profiles[settings.activeProfileID];
                    if (activeProfile.dbName) {
                        settings.valid = true;
                    } else {
                        settings.valid = false;
                    }
                    if (activeProfile.remotesync) {
                        if (activeProfile.user && activeProfile.password) {
                            settings.valid = true;
                        } else {
                            settings.valid = false;
                        }
                    }
                } else {
                    settings.valid = false;
                }
            } else {
                settings = {};
                settings.valid = false;
                settings.activeProfileID = 0;
                settings.profiles = [];
                settings.profiles.push({});
            }
            settings.activeProfile = function() {
                return settings.profiles[settings.activeProfileID];
            };
            $rootScope.settings = settings;
            return settings;
        }<commit_msg>Fix URL handling<commit_after>/**
 * @ngdoc service
 * @name settingsService
 *
 * @module flynnBookScannerApp
 *
 * @description
 * Provides access to the book inventory. Used PouchDB as backend.
 */
app.service('settingsService', ['$rootScope', '$log', '$http', 'localStorageService', 'APP_CONFIG',
    function($rootScope, $log, $http, localStorage, APP_CONFIG) {
        'use strict';

        function saveSettings(pConfig) {
            localStorage.remove('flynn_app.settings');
            var config = pConfig;
            if (!config.appConfig || APP_CONFIG.update) {
                config.appConfig = APP_CONFIG;
            }
            localStorage.add('flynn_app.settings', config);
        }

        function loadSettings() {
            $log.debug('Loading settings from local storage');
            var settings = localStorage.get('flynn_app.settings');
            if (settings) {
                // validate settings
                if (settings.profiles && settings.profiles[settings.activeProfileID]) {
                    var activeProfile = settings.profiles[settings.activeProfileID];
                    if (activeProfile.dbName) {
                        settings.valid = true;
                    } else {
                        settings.valid = false;
                    }
                    if (activeProfile.remotesync) {
                        if (activeProfile.user && activeProfile.password) {
                            settings.valid = true;
                        } else {
                            settings.valid = false;
                        }
                    }
                } else {
                    settings.valid = false;
                }
            } else {
                settings = {};
                settings.valid = false;
                settings.appConfig = APP_CONFIG;
                settings.activeProfileID = 0;
                settings.profiles = [];
                settings.profiles.push({});
            }
            settings.activeProfile = function() {
                return settings.profiles[settings.activeProfileID];
            };
            $rootScope.settings = settings;
            return settings;
        }
{'fraction_non_alphanumeric': 0.0984396512161542, 'fraction_numerical': 0.0004589261128958238, 'mean_word_length': 1.3677349266702878, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1773226', 'n_tokens_mistral': 1040, 'n_tokens_neox': 978, 'n_words': 204}