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

Add optional origin to withUrl #38

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

benbjurstrom
Copy link
Contributor

This pull request adds an optional $origin parameter to the withUrl() method allowing users to set a fixed origin such as https://foo.com. This useful to prevent duplicate content issues with publicly accessible test environments or underlying serverless functions that alias to your domain.

Comment on lines 129 to 130
->toContain('<meta property="og:url" content="https://foo.com/testing/5" />')
->toContain('<link rel="canonical" href="https://foo.com/testing/5" />');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you link MDN docs or something where I can see that both og:url and canonical should be the canonical link?

Copy link
Contributor Author

@benbjurstrom benbjurstrom Nov 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package is already coupling og:url and canonical together. All my pull request does is give users the option to manually set the origin.

@if(seo('url'))
<meta property="og:url" content="@seo('url')">
<link rel="canonical" href="@seo('url')">
@endif

@@ -224,9 +224,13 @@ public function favicon(): static
}

/** Append canonical URL tags to the document head. */
public function withUrl(): static
public function withUrl(?string $origin = null): static
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is origin the right term here, or would canonical be more accurate?

Copy link
Contributor Author

@benbjurstrom benbjurstrom Nov 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This RFC says the scheme/host/port combination is an origin. Note that's all we're passing in here. The full canonical url is still derived from the request path.

https://www.rfc-editor.org/rfc/rfc6454#section-5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants