¿Qué sucede si <base href ...> se configura con una barra doble?
Me gusta entender cómo usar un<base href="" />
valor para mi rastreador web, así que probé varias combinaciones con los principales navegadores y finalmente encontré algo con barras dobles que no entiendo.
Si no le gusta leer todo, salte a los resultados de la prueba deD yE. Demostración de todas las pruebas:
http://gutt.it/basehref.php
Paso a paso los resultados de mi prueba al llamarhttp://example.com/images.html
:
A - href base múltiple
<html>
<head>
<base target="_blank" />
<base href="http://example.com/images/" />
<base href="http://example.com/" />
</head>
<body>
<img src="/images/image.jpg">
<img src="image.jpg">
<img src="./image.jpg">
<img src="images/image.jpg"> not found
<img src="/image.jpg"> not found
<img src="../image.jpg"> not found
</body>
</html>
Conclusión
<base>
conhref
cuentauna fuente que comienza con/
apunta a la raíz../
sube una carpetaB - Sin barra inclinada
<html>
<head>
<base href="http://example.com/images" />
</head>
<body>
<img src="/images/image.jpg">
<img src="image.jpg"> not found
<img src="./image.jpg"> not found
<img src="images/image.jpg">
<img src="/image.jpg"> not found
<img src="../image.jpg"> not found
</body>
</html>
Conclusión
<base href>
ignora todo después de la última barra tanhttp://example.com/images
se conviertehttp://example.com/
C - Cómo debería ser
<html>
<head>
<base href="http://example.com/" />
</head>
<body>
<img src="/images/image.jpg">
<img src="image.jpg"> not found
<img src="./image.jpg"> not found
<img src="images/image.jpg">
<img src="/image.jpg"> not found
<img src="../image.jpg"> not found
</body>
</html>
Conclusión
D - Doble barra
<html>
<head>
<base href="http://example.com/images//" />
</head>
<body>
<img src="/images/image.jpg">
<img src="image.jpg">
<img src="./image.jpg">
<img src="images/image.jpg"> not found
<img src="/image.jpg"> not found
<img src="../image.jpg">
</body>
</html>
E - Doble barra con espacios en blanco
<html>
<head>
<base href="http://example.com/images/ /" />
</head>
<body>
<img src="/images/image.jpg">
<img src="image.jpg"> not found
<img src="./image.jpg"> not found
<img src="images/image.jpg"> not found
<img src="/image.jpg"> not found
<img src="../image.jpg">
</body>
</html>
Ambas no son URL "válidas", sino resultados reales de mi rastreador web. Por favor explique qué sucedió enD yE ese../image.jpg
podría ser encontrado y por qué el espacio en blanco hace una diferencia?
Solo por su interés:
<base href="http://example.com//" />
es lo mismo quePrueba C<base href="http://example.com/ /" />
Es completamente diferente. Solamente../image.jpg
es encontrado<base href="a/" />
encuentra solo/images/image.jpg