DEV: Add support for .well-known/apple-app-site-association (#31798)

We already support `/apple-app-site-association` at the root. Apple also
accepts `.well-known/apple-app-site-association` as a valid path so this
adds that as well, just in case.
This commit is contained in:
Penar Musaraj
2025-03-13 10:49:47 -04:00
committed by GitHub
parent e9eb6a916d
commit ef006ec76b
2 changed files with 13 additions and 0 deletions

View File

@ -1574,7 +1574,10 @@ Discourse::Application.routes.draw do
get "manifest.webmanifest" => "metadata#manifest", :as => :manifest
get "manifest.json" => "metadata#manifest"
get ".well-known/assetlinks.json" => "metadata#app_association_android"
# Apple accepts either of these paths for the apple-app-site-association file
# Might as well support both
get "apple-app-site-association" => "metadata#app_association_ios", :format => false
get ".well-known/apple-app-site-association" => "metadata#app_association_ios", :format => false
get "opensearch" => "metadata#opensearch", :constraints => { format: :xml }
scope "/tag/:tag_id" do

View File

@ -164,6 +164,9 @@ RSpec.describe MetadataController do
it "returns 404 by default" do
get "/apple-app-site-association"
expect(response.status).to eq(404)
get "/.well-known/apple-app-site-association"
expect(response.status).to eq(404)
end
it "returns the right output" do
@ -181,6 +184,13 @@ RSpec.describe MetadataController do
expect(response.media_type).to eq("application/json")
expect(response.headers["Cache-Control"]).to eq("max-age=60, private")
get "/.well-known/apple-app-site-association"
expect(response.status).to eq(200)
expect(response.body).to include("applinks")
expect(response.media_type).to eq("application/json")
expect(response.headers["Cache-Control"]).to eq("max-age=60, private")
get "/apple-app-site-association.json"
expect(response.status).to eq(404)
end