We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
The purl of Alpine ecosystem is inconsistent with purl-spec
According to [**purl-type `apk`**](https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst#apk) ([PR](https://github.com/package-url/purl-spec/pull/171)), it seems that the purl type of `Alpine` should be `apk` and the purl namespace can be `alpine`. In this project, however, the purl type of `Alpine` is `alpine`.

As a result, the purl of a package is **different** when apply different standards. For example, the purl of the `curl` package is `pkg:apk/alpine/curl` according to purl-spec while it is `pkg:alpine/curl` in this project.



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `osv/purl_helpers.py`
Content:
```
1 # Copyright 2022 Google LLC
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 """PURL conversion utilities."""
15 
16 from urllib.parse import quote
17 
18 PURL_ECOSYSTEMS = {
19     'crates.io': 'cargo',
20     'Debian': 'deb',
21     'Hex': 'hex',
22     'Go': 'golang',
23     'Maven': 'maven',
24     'NuGet': 'nuget',
25     'npm': 'npm',
26     'Packagist': 'composer',
27     'OSS-Fuzz': 'generic',
28     'PyPI': 'pypi',
29     'RubyGems': 'gem',
30 }
31 
32 
33 def _url_encode(package_name):
34   """URL encode a PURL `namespace/name` or `name`."""
35   parts = package_name.split('/')
36   return '/'.join(quote(p) for p in parts)
37 
38 
39 def package_to_purl(ecosystem, package_name):
40   """Convert a ecosystem and package name to PURL."""
41   purl_type = PURL_ECOSYSTEMS.get(ecosystem)
42   if not purl_type:
43     return None
44 
45   suffix = ''
46 
47   if purl_type == 'maven':
48     # PURLs use / to separate the group ID and the artifact ID.
49     package_name = package_name.replace(':', '/', 1)
50 
51   if purl_type == 'deb':
52     package_name = 'debian/' + package_name
53     suffix = '?arch=source'
54 
55   return f'pkg:{purl_type}/{_url_encode(package_name)}{suffix}'
56
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/osv/purl_helpers.py b/osv/purl_helpers.py
--- a/osv/purl_helpers.py
+++ b/osv/purl_helpers.py
@@ -16,6 +16,7 @@
 from urllib.parse import quote
 
 PURL_ECOSYSTEMS = {
+    'Alpine': 'apk',
     'crates.io': 'cargo',
     'Debian': 'deb',
     'Hex': 'hex',
@@ -48,8 +49,12 @@
     # PURLs use / to separate the group ID and the artifact ID.
     package_name = package_name.replace(':', '/', 1)
 
-  if purl_type == 'deb':
+  if purl_type == 'deb' and ecosystem == 'Debian':
     package_name = 'debian/' + package_name
     suffix = '?arch=source'
 
+  if purl_type == 'apk' and ecosystem == 'Alpine':
+    package_name = 'alpine/' + package_name
+    suffix = '?arch=source'
+
   return f'pkg:{purl_type}/{_url_encode(package_name)}{suffix}'

{"golden_diff": "diff --git a/osv/purl_helpers.py b/osv/purl_helpers.py\n--- a/osv/purl_helpers.py\n+++ b/osv/purl_helpers.py\n@@ -16,6 +16,7 @@\n from urllib.parse import quote\n \n PURL_ECOSYSTEMS = {\n+    'Alpine': 'apk',\n     'crates.io': 'cargo',\n     'Debian': 'deb',\n     'Hex': 'hex',\n@@ -48,8 +49,12 @@\n     # PURLs use / to separate the group ID and the artifact ID.\n     package_name = package_name.replace(':', '/', 1)\n \n-  if purl_type == 'deb':\n+  if purl_type == 'deb' and ecosystem == 'Debian':\n     package_name = 'debian/' + package_name\n     suffix = '?arch=source'\n \n+  if purl_type == 'apk' and ecosystem == 'Alpine':\n+    package_name = 'alpine/' + package_name\n+    suffix = '?arch=source'\n+\n   return f'pkg:{purl_type}/{_url_encode(package_name)}{suffix}'\n", "issue": "The purl of Alpine ecosystem is inconsistent with purl-spec\nAccording to [**purl-type `apk`**](https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst#apk) ([PR](https://github.com/package-url/purl-spec/pull/171)), it seems that the purl type of `Alpine` should be `apk` and the purl namespace can be `alpine`. In this project, however, the purl type of `Alpine` is `alpine`.\r\n\r\nAs a result, the purl of a package is **different** when apply different standards. For example, the purl of the `curl` package is `pkg:apk/alpine/curl` according to purl-spec while it is `pkg:alpine/curl` in this project.\r\n\r\n\n", "before_files": [{"content": "# Copyright 2022 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"PURL conversion utilities.\"\"\"\n\nfrom urllib.parse import quote\n\nPURL_ECOSYSTEMS = {\n    'crates.io': 'cargo',\n    'Debian': 'deb',\n    'Hex': 'hex',\n    'Go': 'golang',\n    'Maven': 'maven',\n    'NuGet': 'nuget',\n    'npm': 'npm',\n    'Packagist': 'composer',\n    'OSS-Fuzz': 'generic',\n    'PyPI': 'pypi',\n    'RubyGems': 'gem',\n}\n\n\ndef _url_encode(package_name):\n  \"\"\"URL encode a PURL `namespace/name` or `name`.\"\"\"\n  parts = package_name.split('/')\n  return '/'.join(quote(p) for p in parts)\n\n\ndef package_to_purl(ecosystem, package_name):\n  \"\"\"Convert a ecosystem and package name to PURL.\"\"\"\n  purl_type = PURL_ECOSYSTEMS.get(ecosystem)\n  if not purl_type:\n    return None\n\n  suffix = ''\n\n  if purl_type == 'maven':\n    # PURLs use / to separate the group ID and the artifact ID.\n    package_name = package_name.replace(':', '/', 1)\n\n  if purl_type == 'deb':\n    package_name = 'debian/' + package_name\n    suffix = '?arch=source'\n\n  return f'pkg:{purl_type}/{_url_encode(package_name)}{suffix}'\n", "path": "osv/purl_helpers.py"}], "after_files": [{"content": "# Copyright 2022 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"PURL conversion utilities.\"\"\"\n\nfrom urllib.parse import quote\n\nPURL_ECOSYSTEMS = {\n    'Alpine': 'apk',\n    'crates.io': 'cargo',\n    'Debian': 'deb',\n    'Hex': 'hex',\n    'Go': 'golang',\n    'Maven': 'maven',\n    'NuGet': 'nuget',\n    'npm': 'npm',\n    'Packagist': 'composer',\n    'OSS-Fuzz': 'generic',\n    'PyPI': 'pypi',\n    'RubyGems': 'gem',\n}\n\n\ndef _url_encode(package_name):\n  \"\"\"URL encode a PURL `namespace/name` or `name`.\"\"\"\n  parts = package_name.split('/')\n  return '/'.join(quote(p) for p in parts)\n\n\ndef package_to_purl(ecosystem, package_name):\n  \"\"\"Convert a ecosystem and package name to PURL.\"\"\"\n  purl_type = PURL_ECOSYSTEMS.get(ecosystem)\n  if not purl_type:\n    return None\n\n  suffix = ''\n\n  if purl_type == 'maven':\n    # PURLs use / to separate the group ID and the artifact ID.\n    package_name = package_name.replace(':', '/', 1)\n\n  if purl_type == 'deb' and ecosystem == 'Debian':\n    package_name = 'debian/' + package_name\n    suffix = '?arch=source'\n\n  if purl_type == 'apk' and ecosystem == 'Alpine':\n    package_name = 'alpine/' + package_name\n    suffix = '?arch=source'\n\n  return f'pkg:{purl_type}/{_url_encode(package_name)}{suffix}'\n", "path": "osv/purl_helpers.py"}]}