Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative URLs should be made absolute to promote embeddability #4599

Closed
westonruter opened this issue Apr 16, 2020 · 1 comment · May be fixed by #4284
Closed

Relative URLs should be made absolute to promote embeddability #4599

westonruter opened this issue Apr 16, 2020 · 1 comment · May be fixed by #4284
Labels
Bug Something isn't working Groomed Integration: PWA P2 Low priority REST API Issues, features related to REST API WS:Core Work stream for Plugin core

Comments

@westonruter
Copy link
Member

westonruter commented Apr 16, 2020

Bug Description

When a stylesheet does not exist on the filesystem but points to an endpoint that returns a stylesheet, a relative path does not work. Relative stylesheet URLs fail to be fetched.

Additionally, links and resources embedded on the page which make use of relative URLs need to also be made absolute so that AMP pages generated by the plugin are suitable to be embedded in cross-domain contexts such as with the AMP Shadow DOM API, such as in a headless context. This is also important for content being served by the REST API. See #1014.

Expected Behaviour

All relative URLs should appear as absolute in AMP pages, whether they be for stylesheets, fonts, images, links, audio, video, iframes, etc.

Steps to reproduce

Plugin code to reproduce this issue:

<?php
/**
 * Plugin Name: add foo/bar/baz stylesheet
 */

add_action( 'parse_request', function( WP $wp ) {
	if ( 'foo/bar/baz' !== $wp->request ) {
		return;
	}

	header( 'content-type: text/css' );
	echo 'body { border: solid 100px red; }';

	exit;
} );

add_action( 'wp_head', function() {
    echo '<link rel="stylesheet" href="/foo/bar/baz/">';
} );

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Implementation brief

QA testing instructions

Demo

Changelog entry

@westonruter westonruter added Integration: PWA REST API Issues, features related to REST API labels Apr 16, 2020
@amedina amedina added the P1 Medium priority label May 14, 2020
@westonruter
Copy link
Member Author

Making relative URLs absolute will also prevent validation errors stemming from disallowed relative URLs, for example: https://wordpress.org/support/topic/app-banners-for-amp/#post-12854027

@kmyram kmyram added the WS:Core Work stream for Plugin core label Aug 5, 2020
@kmyram kmyram added Bug Something isn't working Groomed P2 Low priority and removed P1 Medium priority labels Nov 10, 2020
@westonruter westonruter closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2023
@github-project-automation github-project-automation bot moved this to Backlog in Ongoing Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Groomed Integration: PWA P2 Low priority REST API Issues, features related to REST API WS:Core Work stream for Plugin core
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants