title: SwiftUI: detect origin domain when dropped from a website
body: <p>In a <strong>macOS</strong> app (target: 12.3), I support dropping images from websites.<br />
  I would like to detect the domain of the website that the image was dropped from. I would show this domain in a confirmation dialog: &quot;Are you sure you want to download this file from ?&quot;<br />
  This origin is often different than the parsed <code>URL.host</code>.</p>
  <br />
  <p>E.g. if I drag and drop an image from unsplash.com (<code>https://unsplash.com/photos/&lt;photo-id&gt;</code>), the host is <code>images.unsplash.com</code>.<br />
  Some other websites don't even use their own subdomain for static files so <code>host</code> can be e.g. an AWS Cloudfront domain.</p>
  <br />
  <p>I checked the docs for <code>NSItemProvider</code>, <code>URL</code> and <code>NSURL</code>, but haven't found a solution yet.<br />
  Do you have any idea, e.g. do you know if <code>NSItemProvider</code> contains this info?</p>
  <pre class="lang-swift prettyprint-override"><code>import SwiftUI
  
  struct ContentView_Drop: View {
      var body: some View {
          Color.gray.onDrop(of: [.url], isTargeted: nil) { providers in
              guard let provider = providers.first else { return false }
              provider.loadObject(ofClass: URL.self) { url, _ in
                  if let url = url {
                      print(&quot;Dropped a url&quot;)
                      print(&quot;URL host: \(url.host)&quot;) // E.g. something.cloudfront.net
                      print(&quot;Drop origin: ???&quot;) // E.g. example.com
                  }
              }
              return true
          }
      }
  }
  
  </code></pre>