Skip to content

Commit

Permalink
Remove trailing slash from absolute home_url meta (#356)
Browse files Browse the repository at this point in the history
* update tests

* pass tests

* fix more tests

* another one

* Diff (our pint.json doesn't enforce this).

---------

Co-authored-by: Jesse Leite <[email protected]>
  • Loading branch information
edalzell and jesseleite authored Oct 16, 2024
1 parent fd6eb1e commit 5bfdf14
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Cascade.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function get()
'canonical_url' => $this->canonicalUrl(),
'prev_url' => $this->prevUrl(),
'next_url' => $this->nextUrl(),
'home_url' => URL::makeAbsolute('/'),
'home_url' => Str::removeRight(URL::makeAbsolute('/'), '/'),
'humans_txt' => $this->humans(),
'site' => $this->site(),
'alternate_locales' => $alternateLocales = $this->alternateLocales(),
Expand Down
8 changes: 4 additions & 4 deletions tests/CascadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function it_generates_seo_cascade_from_site_defaults_and_home_entry()
'canonical_url' => 'http://cool-runnings.com',
'prev_url' => null,
'next_url' => null,
'home_url' => 'http://cool-runnings.com/',
'home_url' => 'http://cool-runnings.com',
'humans_txt' => 'http://cool-runnings.com/humans.txt',
'site' => Site::get('default'),
'alternate_locales' => [],
Expand Down Expand Up @@ -77,7 +77,7 @@ public function it_overwrites_data_in_cascade()
'canonical_url' => 'http://cool-runnings.com',
'prev_url' => null,
'next_url' => null,
'home_url' => 'http://cool-runnings.com/',
'home_url' => 'http://cool-runnings.com',
'humans_txt' => 'http://cool-runnings.com/humans.txt',
'site' => Site::get('default'),
'alternate_locales' => [],
Expand Down Expand Up @@ -166,7 +166,7 @@ public function it_generates_seo_cascade_without_exception_when_no_home_entry_ex
'canonical_url' => 'http://cool-runnings.com',
'prev_url' => null,
'next_url' => null,
'home_url' => 'http://cool-runnings.com/',
'home_url' => 'http://cool-runnings.com',
'humans_txt' => 'http://cool-runnings.com/humans.txt',
'site' => Site::get('default'),
'alternate_locales' => [],
Expand Down Expand Up @@ -225,7 +225,7 @@ public function it_generates_seo_cascade_from_custom_site_defaults_path()
'canonical_url' => 'http://cool-runnings.com',
'prev_url' => null,
'next_url' => null,
'home_url' => 'http://cool-runnings.com/',
'home_url' => 'http://cool-runnings.com',
'humans_txt' => 'http://cool-runnings.com/humans.txt',
'site' => Site::get('default'),
'alternate_locales' => [],
Expand Down
8 changes: 4 additions & 4 deletions tests/GraphQLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function it_queries_for_entry_seo_meta_html()
'<meta property="og:image:alt" content="" />',
'<meta name="twitter:image" content="http://cool-runnings.com/assets/img/stetson.jpg" />',
'<meta name="twitter:image:alt" content="" />',
'<link href="http://cool-runnings.com/" rel="home" />',
'<link href="http://cool-runnings.com" rel="home" />',
'<link href="http://cool-runnings.com/nectar" rel="canonical" />',
'<link type="text/plain" rel="author" href="http://cool-runnings.com/humans.txt" />',
])->implode('');
Expand Down Expand Up @@ -145,7 +145,7 @@ public function it_queries_for_entry_seo_cascade_so_user_can_render_custom_meta(
'alternate_locales' => [],
'prev_url' => null,
'next_url' => null,
'home_url' => 'http://cool-runnings.com/',
'home_url' => 'http://cool-runnings.com',
'humans_txt' => 'http://cool-runnings.com/humans.txt',
'twitter_card' => 'summary_large_image',
'twitter_handle' => null,
Expand Down Expand Up @@ -182,7 +182,7 @@ public function it_queries_for_term_seo_meta_html()
'<meta property="og:locale" content="en_US" />',
'<meta name="twitter:card" content="summary_large_image" />',
'<meta name="twitter:title" content="Dance" />',
'<link href="http://cool-runnings.com/" rel="home" />',
'<link href="http://cool-runnings.com" rel="home" />',
'<link href="http://cool-runnings.com/topics/dance" rel="canonical" />',
'<link type="text/plain" rel="author" href="http://cool-runnings.com/humans.txt" />',
])->implode('');
Expand Down Expand Up @@ -259,7 +259,7 @@ public function it_queries_for_term_seo_cascade_so_user_can_render_custom_meta()
'alternate_locales' => [],
'prev_url' => null,
'next_url' => null,
'home_url' => 'http://cool-runnings.com/',
'home_url' => 'http://cool-runnings.com',
'humans_txt' => 'http://cool-runnings.com/humans.txt',
'twitter_card' => 'summary_large_image',
'twitter_handle' => null,
Expand Down
2 changes: 1 addition & 1 deletion tests/HumansTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function it_outputs_humans_txt()
/* TEAM */
Creator: Site Name
URL: http://cool-runnings.com/
URL: http://cool-runnings.com
Description: I see a bad-ass mother.
/* THANKS */
Expand Down
2 changes: 1 addition & 1 deletion tests/Localized/GraphQLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function it_queries_multisite_for_canonical_url_and_alternate_locales_in_
'<meta name="twitter:card" content="summary_large_image" />',
'<meta name="twitter:title" content="Les Nectar of the Gods" />',
'<meta name="twitter:description" content="The day started just like any other. Wake up at 5:30am, brush my teeth, bathe in a tub of warm milk, and trim my toenails while quietly resenting the fact that Flipper was on Nickelodeon at this hour instead of Rocko&#039;s Modern Life. That would have to wait until 5:30pm for that, and I am impatient.In truth, the day wou..." />',
'<link href="http://cool-runnings.com/" rel="home" />',
'<link href="http://cool-runnings.com" rel="home" />',
'<link href="http://cool-runnings.com/fr/nectar" rel="canonical" />',
'<link rel="alternate" href="http://cool-runnings.com/fr/nectar" hreflang="fr" />',
'<link rel="alternate" href="http://cool-runnings.com/nectar" hreflang="en" />',
Expand Down
8 changes: 4 additions & 4 deletions tests/MetaTagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function it_generates_normalized_meta($viewType)
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Home" />
<meta name="twitter:description" content="I see a bad-ass mother." />
<link href="http://cool-runnings.com/" rel="home" />
<link href="http://cool-runnings.com" rel="home" />
<link href="http://cool-runnings.com" rel="canonical" />
<link type="text/plain" rel="author" href="http://cool-runnings.com/humans.txt" />
EOT;
Expand Down Expand Up @@ -103,7 +103,7 @@ public function it_generates_normalized_meta_when_visiting_statamic_route_with_r
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="The View" />
<meta name="twitter:description" content="A wonderful view!" />
<link href="http://cool-runnings.com/" rel="home" />
<link href="http://cool-runnings.com" rel="home" />
<link href="http://cool-runnings.com/the-view" rel="canonical" />
<link type="text/plain" rel="author" href="http://cool-runnings.com/humans.txt" />
EOT;
Expand Down Expand Up @@ -383,7 +383,7 @@ public function it_generates_home_url_for_entry_meta($viewType)

$response = $this->get('/about');
$response->assertSee("<h1>{$viewType}</h1>", false);
$response->assertSee('<link href="http://cool-runnings.com/" rel="home" />', false);
$response->assertSee('<link href="http://cool-runnings.com" rel="home" />', false);
}

/**
Expand Down Expand Up @@ -744,7 +744,7 @@ public function it_generates_normalized_meta_from_custom_site_defaults_path($vie
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Home" />
<meta name="twitter:description" content="I see a bad-ass mother." />
<link href="http://cool-runnings.com/" rel="home" />
<link href="http://cool-runnings.com" rel="home" />
<link href="http://cool-runnings.com" rel="canonical" />
<link type="text/plain" rel="author" href="http://cool-runnings.com/humans.txt" />
EOT;
Expand Down

0 comments on commit 5bfdf14

Please sign in to comment.