title: Add section to URL in swift
body: <p>A URL can have a <code>#sectionName</code> component, which directs to the part of the site where that section begins.</p>
  
  <p>In Swift I am trying to add that component, but it does not work. I am trying:</p>
  
  <pre><code>let url = URL(string: "example.com/component1")!
  </code></pre>
  
  <p>Later I am trying to do:</p>
  
  <pre><code>url.appendingPathComponent("#sectionName")
  </code></pre>
  
  <p>but it returns <code>example.com/component1%23sectionName</code> instead of <code>example.com/component1#sectionName</code>.</p>
  
  <p>At the time the URL is created I still don't have the name of the section, so I can't do <code>URL(string: "example.com/component1#sectionName")</code></p>
  
  <p>I've also tried escaping the <code>#</code> with <code>\#</code> or <code>\\#</code>, but it does not work. Any ideas how to add a component that is a section? </p>