File indexing completed on 2024-05-05 03:56:11

0001 /*
0002     localdomainurifilter.h
0003 
0004     This file is part of the KDE project
0005     SPDX-FileCopyrightText: 2002 Lubos Lunak <llunak@suse.cz>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #ifndef LOCALDOMAINURIFILTER_H
0011 #define LOCALDOMAINURIFILTER_H
0012 
0013 #include "kurifilterplugin_p.h"
0014 #include <QRegularExpression>
0015 
0016 /**
0017  This filter takes care of hostnames in the local search domain.
0018  If you're in domain domain.org which has a host intranet.domain.org
0019  and the typed URI is just intranet, check if there's a host
0020  intranet.domain.org and if yes, it's a network URI.
0021 */
0022 class LocalDomainUriFilter : public KUriFilterPlugin
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     using KUriFilterPlugin::KUriFilterPlugin;
0028     bool filterUri(KUriFilterData &data) const override;
0029 
0030 private:
0031     bool exists(const QString &) const;
0032 
0033     const QRegularExpression m_hostPortPattern{
0034         QRegularExpression::anchoredPattern(uR"--([a-zA-Z0-9][a-zA-Z0-9+-]*(?:\:[0-9]{1,5})?(?:/[\w:@&=+$,-.!~*'()]*)*)--"),
0035     };
0036 };
0037 
0038 #endif