Skip to content

A platform for community discussion. Free, open, simple.

FIX: Permalinks should redirect to category URL including the ID

David Taylor3215f2b6ee68
diff --git a/app/models/permalink.rb b/app/models/permalink.rb
index c6c28026ee9..925f640f7e0 100644
--- a/app/models/permalink.rb
+++ b/app/models/permalink.rb
@@ -79,7 +79,7 @@ class Permalink < ActiveRecord::Base
return external_url if external_url
return "#{Discourse::base_uri}#{post.url}" if post
return topic.relative_url if topic
- return category.url if category
+ return "#{category.url}/#{category.id}" if category
nil
end
diff --git a/spec/models/permalink_spec.rb b/spec/models/permalink_spec.rb
index 15c47b0032e..8cd9d30a46a 100644
--- a/spec/models/permalink_spec.rb
+++ b/spec/models/permalink_spec.rb
@@ -62,7 +62,7 @@ describe Permalink do
it "returns a category url when category_id is set" do
permalink.category_id = category.id
- expect(target_url).to eq(category.url)
+ expect(target_url).to eq("#{category.url}/#{category.id}")
end
it "returns nil when category_id is set but category is not found" do