Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
S
stats-facil
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
facil
stats-facil
Validations
0c051152
Valider
0c051152
rédigé
il y a 10 ans
par
mattab
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Accept URLs formatted as //domain/path
Fixes
https://github.com/piwik/piwik/pull/6652
parent
a0d3bf94
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
2
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
core/UrlHelper.php
+2
-2
2 ajouts, 2 suppressions
core/UrlHelper.php
tests/PHPUnit/Unit/UrlHelperTest.php
+11
-1
11 ajouts, 1 suppression
tests/PHPUnit/Unit/UrlHelperTest.php
avec
13 ajouts
et
3 suppressions
core/UrlHelper.php
+
2
−
2
Voir le fichier @
0c051152
...
@@ -101,8 +101,8 @@ class UrlHelper
...
@@ -101,8 +101,8 @@ class UrlHelper
*/
*/
public
static
function
isLookLikeUrl
(
$url
)
public
static
function
isLookLikeUrl
(
$url
)
{
{
return
preg_match
(
'~^(ftp|news|http|https)?://(.*)$~D'
,
$url
,
$matches
)
!==
0
return
preg_match
(
'~^(
(
ftp|news|http|https)?:
)?
//(.*)$~D'
,
$url
,
$matches
)
!==
0
&&
strlen
(
$matches
[
2
])
>
0
;
&&
strlen
(
$matches
[
3
])
>
0
;
}
}
/**
/**
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
tests/PHPUnit/Unit/UrlHelperTest.php
+
11
−
1
Voir le fichier @
0c051152
...
@@ -28,9 +28,17 @@ class Core_UrlHelperTest extends \PHPUnit_Framework_TestCase
...
@@ -28,9 +28,17 @@ class Core_UrlHelperTest extends \PHPUnit_Framework_TestCase
array
(
'news://www.pi-wik.org'
,
true
),
array
(
'news://www.pi-wik.org'
,
true
),
array
(
'https://www.tëteâ.org'
,
true
),
array
(
'https://www.tëteâ.org'
,
true
),
array
(
'http://汉语/漢語.cn'
,
true
),
//chinese
array
(
'http://汉语/漢語.cn'
,
true
),
//chinese
// valid network-path reference RFC3986
array
(
'//piwik.org'
,
true
),
array
(
'//piwik/hello?world=test&test'
,
true
),
array
(
'//piwik.org/hello?world=test&test'
,
true
),
// invalid urls
// invalid urls
array
(
'it doesnt look like url'
,
false
),
array
(
'it doesnt look like url'
,
false
),
array
(
'/index?page=test'
,
false
),
array
(
'/index?page=test'
,
false
),
array
(
'http:/index?page=test'
,
false
),
array
(
'http/index?page=test'
,
false
),
array
(
'test.html'
,
false
),
array
(
'test.html'
,
false
),
array
(
'/\/\/\/\/\/\\\http://test.com////'
,
false
),
array
(
'/\/\/\/\/\/\\\http://test.com////'
,
false
),
array
(
'jmleslangues.php'
,
false
),
array
(
'jmleslangues.php'
,
false
),
...
@@ -46,7 +54,7 @@ class Core_UrlHelperTest extends \PHPUnit_Framework_TestCase
...
@@ -46,7 +54,7 @@ class Core_UrlHelperTest extends \PHPUnit_Framework_TestCase
*/
*/
public
function
testIsUrl
(
$url
,
$isValid
)
public
function
testIsUrl
(
$url
,
$isValid
)
{
{
$this
->
assertEquals
(
$isValid
,
UrlHelper
::
isLookLikeUrl
(
$url
));
$this
->
assertEquals
(
$isValid
,
UrlHelper
::
isLookLikeUrl
(
$url
)
,
"
$url
failed test"
);
}
}
/**
/**
...
@@ -196,6 +204,8 @@ class Core_UrlHelperTest extends \PHPUnit_Framework_TestCase
...
@@ -196,6 +204,8 @@ class Core_UrlHelperTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
''
,
UrlHelper
::
getHostFromUrl
(
null
));
$this
->
assertEquals
(
''
,
UrlHelper
::
getHostFromUrl
(
null
));
$this
->
assertEquals
(
'localhost'
,
UrlHelper
::
getHostFromUrl
(
'http://localhost'
));
$this
->
assertEquals
(
'localhost'
,
UrlHelper
::
getHostFromUrl
(
'http://localhost'
));
$this
->
assertEquals
(
'localhost'
,
UrlHelper
::
getHostFromUrl
(
'http://localhost/path'
));
$this
->
assertEquals
(
'localhost'
,
UrlHelper
::
getHostFromUrl
(
'http://localhost/path'
));
$this
->
assertEquals
(
'localhost'
,
UrlHelper
::
getHostFromUrl
(
'//localhost/path'
));
$this
->
assertEquals
(
'localhost'
,
UrlHelper
::
getHostFromUrl
(
'//localhost/path?test=test2'
));
$this
->
assertEquals
(
'localhost'
,
UrlHelper
::
getHostFromUrl
(
'localhost/path'
));
$this
->
assertEquals
(
'localhost'
,
UrlHelper
::
getHostFromUrl
(
'localhost/path'
));
$this
->
assertEquals
(
'sub.localhost'
,
UrlHelper
::
getHostFromUrl
(
'sub.localhost/path'
));
$this
->
assertEquals
(
'sub.localhost'
,
UrlHelper
::
getHostFromUrl
(
'sub.localhost/path'
));
$this
->
assertEquals
(
'sub.localhost'
,
UrlHelper
::
getHostFromUrl
(
'http://sub.localhost/path/?query=test'
));
$this
->
assertEquals
(
'sub.localhost'
,
UrlHelper
::
getHostFromUrl
(
'http://sub.localhost/path/?query=test'
));
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter