mirror of
https://github.com/discourse/discourse.git
synced 2024-12-21 09:23:42 +08:00
e3cfb1967d
All our link validation, and conversion from url -> route/model/query is expensive and prone to bugs. Instead, if people enter a link, we can just use it as-is. Originally all this extra logic was added to handle unusual situations like `/safe-mode`, `/my/...`, etc. However, all of these are now handled correctly by our Ember router, so there is no need for it. Now, we just pass the user-supplied `href` directly to the SectionLink component, and let Ember handle routing to it when clicked. The only functional change here is that we no longer validate internal links by parsing them with the Ember router. But I'd argue this is fine, because the previous logic would cause both false positives (e.g. `/t/123` would be valid, even if topic 123 doesn't exist), and false negatives (for routes which are server-side only, like the new AI share pages).
10 lines
189 B
Ruby
10 lines
189 B
Ruby
# frozen_string_literal: true
|
|
|
|
class SidebarUrlSerializer < ApplicationSerializer
|
|
attributes :id, :name, :value, :icon, :external, :segment
|
|
|
|
def external
|
|
object.external?
|
|
end
|
|
end
|