Repository: praw-dev/praw

Issue:
Support for new reddit share link
### Describe the solution you'd like

Within the past couple of weeks, reddit seems to have made a new format for their share links.

Normally, when you click share -> copy link, you would get a link like the following:
https://www.reddit.com/r/space/comments/15llt1x/two_consecutive_solar_flares_send_potential/?ref=share&ref_source=link

However, on mobile, you now get links like the following:
https://reddit.com/r/space/s/skZgKbbMDq
The string after s/ changes every time you share the link, even if it is the same account on the same post.

When resolving this link, it takes you to the original share link except with a share_id=<string> query on the end:
https://www.reddit.com/r/space/comments/15llt1x/two_consecutive_solar_flares_send_potential/?share_id=T-5Gge1AFaeZCVqp2sW_N

Support for using this new link would be helpful.



### Describe alternatives you've considered

Currently, I have had to use requests to follow the new share link in order to get the original link from headers -> location in order to use praw/asyncpraw. 

### Additional context

_No response_


Discussion:
@Aaeeschylus  Could you please share the workaround that you tried with `requests` ?
> @Aaeeschylus Could you please share the workaround that you tried with `requests` ?

`requests.get(link, allow_redirects=False).headers["Location"]`

Do note, it isn't 100% reliable. Sometimes you need to follow it multiple times before you get the real reddit link.
> > @Aaeeschylus Could you please share the workaround that you tried with `requests` ?
> 
> `requests.get(link, allow_redirects=False).headers["Location"]`
> 
> Do note, it isn't 100% reliable. Sometimes you need to follow it multiple times before you get the real reddit link.

Thanks for sharing this! I tried to run it a couple of times(in loop) but unfortunately it returns the same url back with just `www` added to the mobile `link`.

Edit: Inspired by your idea I found the solution to get the correct url always. We must specify `Host` in request header.
```python
link = 'https://reddit.com/r/space/s/skZgKbbMDq'
h = {'Host': 'www.reddit.com'}
share_url = requests.get(link, headers=h, allow_redirects=False).headers['Location']
```
> > > @Aaeeschylus Could you please share the workaround that you tried with `requests` ?
> > 
> > 
> > `requests.get(link, allow_redirects=False).headers["Location"]`
> > Do note, it isn't 100% reliable. Sometimes you need to follow it multiple times before you get the real reddit link.
> 
> Thanks for sharing this! I tried to run it a couple of times(in loop) but unfortunately it returns the same url back with just `www` added to the mobile `link`.
> 
> Edit: Inspired by your idea I found the solution to get the correct url always. We must specify `Host` in request header.
> 
> ```python
> link = 'https://reddit.com/r/space/s/skZgKbbMDq'
> h = {'Host': 'www.reddit.com'}
> share_url = requests.get(link, headers=h, allow_redirects=False).headers['Location']
> ```

Yeah I would normally either run it multiple times until I got the correct link or just add www to the url. I didnt know about the header part so I will definitely try that if it gives the correct URL every time
This issue is stale because it has been open for 30 days with no activity. 

Remove the Stale label or comment or this will be closed in 30 days.
This issue is stale because it has been open for 30 days with no activity. 

Remove the Stale label or comment or this will be closed in 30 days.
Yes, reddit is still using these stupid new links.

Resolving patch:
diff --git a/praw/models/reddit/redditor.py b/praw/models/reddit/redditor.py
--- a/praw/models/reddit/redditor.py
+++ b/praw/models/reddit/redditor.py
@@ -193,7 +193,7 @@ def _fetch_username(self, fullname: str):
             fullname
         ]["name"]
 
-    def _friend(self, *, data: dict[str:Any], method: str):
+    def _friend(self, *, data: dict[str, Any], method: str):
         url = API_PATH["friend_v1"].format(user=self)
         self._reddit.request(data=dumps(data), method=method, path=url)
 
diff --git a/praw/reddit.py b/praw/reddit.py
--- a/praw/reddit.py
+++ b/praw/reddit.py
@@ -9,6 +9,7 @@
 from itertools import islice
 from logging import getLogger
 from typing import IO, TYPE_CHECKING, Any, Generator, Iterable
+from urllib.parse import urlparse
 from warnings import warn
 
 from prawcore import (
@@ -643,6 +644,16 @@ def _prepare_untrusted_prawcore(self, requestor: prawcore.requestor.Requestor):
         self._read_only_core = session(read_only_authorizer)
         self._prepare_common_authorizer(authenticator)
 
+    def _resolve_share_url(self, url: str) -> str:
+        """Return the canonical URL for a given share URL."""
+        parts = urlparse(url).path.rstrip("/").split("/")
+        if "s" in parts:  # handling new share urls from mobile apps
+            try:
+                self.get(url)
+            except Redirect as e:
+                return e.response.next.url
+        return url
+
     @_deprecate_args("id", "url")
     def comment(
         self, id: str | None = None, *, url: str | None = None
@@ -658,6 +669,8 @@ def comment(
             :meth:`~.Comment.refresh` on the returned :class:`.Comment`.
 
         """
+        if url:
+            url = self._resolve_share_url(url)
         return models.Comment(self, id=id, url=url)
 
     @_deprecate_args("path", "data", "json", "params")
@@ -977,6 +990,8 @@ def submission(
         Either ``id`` or ``url`` can be provided, but not both.
 
         """
+        if url:
+            url = self._resolve_share_url(url)
         return models.Submission(self, id=id, url=url)
 
     def username_available(self, name: str) -> bool:


Test patch:
diff --git a/tests/integration/cassettes/TestComment.test_resolve_from_share_url.json b/tests/integration/cassettes/TestComment.test_resolve_from_share_url.json
new file mode 100644
--- /dev/null
+++ b/tests/integration/cassettes/TestComment.test_resolve_from_share_url.json
@@ -0,0 +1,198 @@
+{
+  "http_interactions": [
+    {
+      "recorded_at": "2023-11-09T19:03:42",
+      "request": {
+        "body": {
+          "encoding": "utf-8",
+          "string": "grant_type=client_credentials"
+        },
+        "headers": {
+          "Accept": [
+            "*/*"
+          ],
+          "Accept-Encoding": [
+            "identity"
+          ],
+          "Authorization": [
+            "Basic <BASIC_AUTH>"
+          ],
+          "Connection": [
+            "close"
+          ],
+          "Content-Length": [
+            "29"
+          ],
+          "Content-Type": [
+            "application/x-www-form-urlencoded"
+          ],
+          "User-Agent": [
+            "<USER_AGENT> PRAW/7.7.2.dev0 prawcore/2.3.0"
+          ]
+        },
+        "method": "POST",
+        "uri": "https://www.reddit.com/api/v1/access_token"
+      },
+      "response": {
+        "body": {
+          "encoding": "UTF-8",
+          "string": "{\"access_token\": \"<ACCESS_TOKEN>\", \"token_type\": \"bearer\", \"expires_in\": 86400, \"scope\": \"*\"}"
+        },
+        "headers": {
+          "Accept-Ranges": [
+            "bytes"
+          ],
+          "Cache-Control": [
+            "private, max-age=3600"
+          ],
+          "Connection": [
+            "close"
+          ],
+          "Content-Length": [
+            "812"
+          ],
+          "Date": [
+            "Thu, 09 Nov 2023 19:03:42 GMT"
+          ],
+          "NEL": [
+            "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 1.0, \"failure_fraction\": 1.0}"
+          ],
+          "Report-To": [
+            "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true,  \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}, {\"group\": \"w3-reporting-csp\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-csp.reddit.com/reports\" }]}"
+          ],
+          "Server": [
+            "snooserv"
+          ],
+          "Set-Cookie": [
+            "edgebucket=ZiuasF2t2VM3rHunbP; Domain=reddit.com; Max-Age=63071999; Path=/;  secure"
+          ],
+          "Strict-Transport-Security": [
+            "max-age=31536000; includeSubdomains"
+          ],
+          "Vary": [
+            "accept-encoding, Accept-Encoding"
+          ],
+          "Via": [
+            "1.1 varnish"
+          ],
+          "X-Content-Type-Options": [
+            "nosniff"
+          ],
+          "X-Frame-Options": [
+            "SAMEORIGIN"
+          ],
+          "X-XSS-Protection": [
+            "1; mode=block"
+          ],
+          "content-type": [
+            "application/json; charset=UTF-8"
+          ],
+          "x-reddit-loid": [
+            "000000000njwzxoaiz.2.1699556622239.Z0FBQUFBQmxUUzBPZm1TOUx4SElwWW1rMG1rSXhZdmRCb2REMm50Vlo3V2xyaUltbnpKZTM4ZVd2cmNmdHRHbktzazFwS2FUNzIxeW5HTmN3MVIxM084NERFdnNHd2RaY2RFTlg1dHBmVFJqQjdBYVZuV1RHRGpzZjk5S3RBcG5laDE1ZFA2WF9vSmc"
+          ]
+        },
+        "status": {
+          "code": 200,
+          "message": "OK"
+        },
+        "url": "https://www.reddit.com/api/v1/access_token"
+      }
+    },
+    {
+      "recorded_at": "2023-11-09T19:03:42",
+      "request": {
+        "body": {
+          "encoding": "utf-8",
+          "string": ""
+        },
+        "headers": {
+          "Accept": [
+            "*/*"
+          ],
+          "Accept-Encoding": [
+            "identity"
+          ],
+          "Authorization": [
+            "bearer <ACCESS_TOKEN>"
+          ],
+          "Connection": [
+            "keep-alive"
+          ],
+          "Cookie": [
+            "edgebucket=ZiuasF2t2VM3rHunbP"
+          ],
+          "User-Agent": [
+            "<USER_AGENT> PRAW/7.7.2.dev0 prawcore/2.3.0"
+          ]
+        },
+        "method": "GET",
+        "uri": "https://www.reddit.com/r/redditdev/s/nGnQE1QkLC?raw_json=1"
+      },
+      "response": {
+        "body": {
+          "encoding": "utf-8",
+          "string": "<a href=\"https://www.reddit.com/r/redditdev/comments/2gmzqe/praw_https_enabled_praw_testing_needed/cklhv0f/?context=3&amp;share_id=vi8DOF9B0U5cJSzhFjDE9&amp;utm_content=1&amp;utm_medium=ios_app&amp;utm_name=ioscss&amp;utm_source=share&amp;utm_term=1\">Moved Permanently</a>.\n\n"
+        },
+        "headers": {
+          "Accept-Ranges": [
+            "bytes"
+          ],
+          "Cache-Control": [
+            "private, max-age=3600"
+          ],
+          "Connection": [
+            "keep-alive"
+          ],
+          "Content-Length": [
+            "275"
+          ],
+          "Date": [
+            "Thu, 09 Nov 2023 19:03:42 GMT"
+          ],
+          "NEL": [
+            "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 1.0, \"failure_fraction\": 1.0}"
+          ],
+          "Report-To": [
+            "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true,  \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}, {\"group\": \"w3-reporting-csp\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-csp.reddit.com/reports\" }]}"
+          ],
+          "Server": [
+            "snooserv"
+          ],
+          "Set-Cookie": [
+            "csv=2; Max-Age=63072000; Domain=.reddit.com; Path=/; Secure; SameSite=None"
+          ],
+          "Strict-Transport-Security": [
+            "max-age=31536000; includeSubdomains"
+          ],
+          "Vary": [
+            "Accept-Encoding"
+          ],
+          "Via": [
+            "1.1 varnish"
+          ],
+          "X-Content-Type-Options": [
+            "nosniff"
+          ],
+          "X-Frame-Options": [
+            "SAMEORIGIN"
+          ],
+          "X-XSS-Protection": [
+            "1; mode=block"
+          ],
+          "content-type": [
+            "text/html; charset=utf-8"
+          ],
+          "location": [
+            "https://www.reddit.com/r/redditdev/comments/2gmzqe/praw_https_enabled_praw_testing_needed/cklhv0f/?context=3&share_id=vi8DOF9B0U5cJSzhFjDE9&utm_content=1&utm_medium=ios_app&utm_name=ioscss&utm_source=share&utm_term=1"
+          ]
+        },
+        "status": {
+          "code": 301,
+          "message": "Moved Permanently"
+        },
+        "url": "https://www.reddit.com/r/redditdev/s/nGnQE1QkLC?raw_json=1"
+      }
+    }
+  ],
+  "recorded_with": "betamax/0.8.1"
+}
diff --git a/tests/integration/cassettes/TestComment.test_resolve_from_share_url__invalid_url.json b/tests/integration/cassettes/TestComment.test_resolve_from_share_url__invalid_url.json
new file mode 100644
--- /dev/null
+++ b/tests/integration/cassettes/TestComment.test_resolve_from_share_url__invalid_url.json
@@ -0,0 +1,201 @@
+{
+  "http_interactions": [
+    {
+      "recorded_at": "2023-11-09T19:04:16",
+      "request": {
+        "body": {
+          "encoding": "utf-8",
+          "string": "grant_type=client_credentials"
+        },
+        "headers": {
+          "Accept": [
+            "*/*"
+          ],
+          "Accept-Encoding": [
+            "identity"
+          ],
+          "Authorization": [
+            "Basic <BASIC_AUTH>"
+          ],
+          "Connection": [
+            "close"
+          ],
+          "Content-Length": [
+            "29"
+          ],
+          "Content-Type": [
+            "application/x-www-form-urlencoded"
+          ],
+          "User-Agent": [
+            "<USER_AGENT> PRAW/7.7.2.dev0 prawcore/2.3.0"
+          ]
+        },
+        "method": "POST",
+        "uri": "https://www.reddit.com/api/v1/access_token"
+      },
+      "response": {
+        "body": {
+          "encoding": "UTF-8",
+          "string": "{\"access_token\": \"<ACCESS_TOKEN>\", \"token_type\": \"bearer\", \"expires_in\": 86400, \"scope\": \"*\"}"
+        },
+        "headers": {
+          "Accept-Ranges": [
+            "bytes"
+          ],
+          "Cache-Control": [
+            "private, max-age=3600"
+          ],
+          "Connection": [
+            "close"
+          ],
+          "Content-Length": [
+            "812"
+          ],
+          "Date": [
+            "Thu, 09 Nov 2023 19:04:16 GMT"
+          ],
+          "NEL": [
+            "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 1.0, \"failure_fraction\": 1.0}"
+          ],
+          "Report-To": [
+            "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true,  \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}, {\"group\": \"w3-reporting-csp\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-csp.reddit.com/reports\" }]}"
+          ],
+          "Server": [
+            "snooserv"
+          ],
+          "Set-Cookie": [
+            "edgebucket=ji5mkxOqhmGDRBCHje; Domain=reddit.com; Max-Age=63071999; Path=/;  secure"
+          ],
+          "Strict-Transport-Security": [
+            "max-age=31536000; includeSubdomains"
+          ],
+          "Vary": [
+            "accept-encoding"
+          ],
+          "Via": [
+            "1.1 varnish"
+          ],
+          "X-Content-Type-Options": [
+            "nosniff"
+          ],
+          "X-Frame-Options": [
+            "SAMEORIGIN"
+          ],
+          "X-XSS-Protection": [
+            "1; mode=block"
+          ],
+          "content-type": [
+            "application/json; charset=UTF-8"
+          ],
+          "x-moose": [
+            "majestic"
+          ],
+          "x-reddit-loid": [
+            "000000000njx1ov2vf.2.1699556656453.Z0FBQUFBQmxUUzB3dEFGY2lCVGlGLTFDbElQd1QweUhMazBJQVNGS2o2eVpZTFJ6ZG9aZEZTTjBNYnB4Wjl0NFFlek5JM1U3M1AzZnB5dFJDaWVSbEd5SEFBLWxOX21NSFpuVjZOTnBablVicENYVEdxYmhHYVlkWVBQQUhhX01uLXM3Y3k4QTY4UEY"
+          ]
+        },
+        "status": {
+          "code": 200,
+          "message": "OK"
+        },
+        "url": "https://www.reddit.com/api/v1/access_token"
+      }
+    },
+    {
+      "recorded_at": "2023-11-09T19:04:16",
+      "request": {
+        "body": {
+          "encoding": "utf-8",
+          "string": ""
+        },
+        "headers": {
+          "Accept": [
+            "*/*"
+          ],
+          "Accept-Encoding": [
+            "identity"
+          ],
+          "Authorization": [
+            "bearer <ACCESS_TOKEN>"
+          ],
+          "Connection": [
+            "keep-alive"
+          ],
+          "Cookie": [
+            "edgebucket=ji5mkxOqhmGDRBCHje"
+          ],
+          "User-Agent": [
+            "<USER_AGENT> PRAW/7.7.2.dev0 prawcore/2.3.0"
+          ]
+        },
+        "method": "GET",
+        "uri": "https://www.reddit.com/r/redditdev/s/WNauetbiNG?raw_json=1"
+      },
+      "response": {
+        "body": {
+          "encoding": "utf-8",
+          "string": "<a href=\"https://www.reddit.com/r/redditdev/comments/2gmzqe/praw_https_enabled_praw_testing_needed/?share_id=oqqXWtvgcCuonkcpck8yD&amp;utm_content=1&amp;utm_medium=ios_app&amp;utm_name=ioscss&amp;utm_source=share&amp;utm_term=1\">Moved Permanently</a>.\n\n"
+        },
+        "headers": {
+          "Accept-Ranges": [
+            "bytes"
+          ],
+          "Cache-Control": [
+            "private, max-age=3600"
+          ],
+          "Connection": [
+            "keep-alive"
+          ],
+          "Content-Length": [
+            "253"
+          ],
+          "Date": [
+            "Thu, 09 Nov 2023 19:04:16 GMT"
+          ],
+          "NEL": [
+            "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 1.0, \"failure_fraction\": 1.0}"
+          ],
+          "Report-To": [
+            "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true,  \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}, {\"group\": \"w3-reporting-csp\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-csp.reddit.com/reports\" }]}"
+          ],
+          "Server": [
+            "snooserv"
+          ],
+          "Set-Cookie": [
+            "csv=2; Max-Age=63072000; Domain=.reddit.com; Path=/; Secure; SameSite=None"
+          ],
+          "Strict-Transport-Security": [
+            "max-age=31536000; includeSubdomains"
+          ],
+          "Vary": [
+            "Accept-Encoding"
+          ],
+          "Via": [
+            "1.1 varnish"
+          ],
+          "X-Content-Type-Options": [
+            "nosniff"
+          ],
+          "X-Frame-Options": [
+            "SAMEORIGIN"
+          ],
+          "X-XSS-Protection": [
+            "1; mode=block"
+          ],
+          "content-type": [
+            "text/html; charset=utf-8"
+          ],
+          "location": [
+            "https://www.reddit.com/r/redditdev/comments/2gmzqe/praw_https_enabled_praw_testing_needed/?share_id=oqqXWtvgcCuonkcpck8yD&utm_content=1&utm_medium=ios_app&utm_name=ioscss&utm_source=share&utm_term=1"
+          ]
+        },
+        "status": {
+          "code": 301,
+          "message": "Moved Permanently"
+        },
+        "url": "https://www.reddit.com/r/redditdev/s/WNauetbiNG?raw_json=1"
+      }
+    }
+  ],
+  "recorded_with": "betamax/0.8.1"
+}
diff --git a/tests/integration/cassettes/TestSubmission.test_resolve_from_share_url.json b/tests/integration/cassettes/TestSubmission.test_resolve_from_share_url.json
new file mode 100644
--- /dev/null
+++ b/tests/integration/cassettes/TestSubmission.test_resolve_from_share_url.json
@@ -0,0 +1,201 @@
+{
+  "http_interactions": [
+    {
+      "recorded_at": "2023-11-09T19:05:44",
+      "request": {
+        "body": {
+          "encoding": "utf-8",
+          "string": "grant_type=client_credentials"
+        },
+        "headers": {
+          "Accept": [
+            "*/*"
+          ],
+          "Accept-Encoding": [
+            "identity"
+          ],
+          "Authorization": [
+            "Basic <BASIC_AUTH>"
+          ],
+          "Connection": [
+            "close"
+          ],
+          "Content-Length": [
+            "29"
+          ],
+          "Content-Type": [
+            "application/x-www-form-urlencoded"
+          ],
+          "User-Agent": [
+            "<USER_AGENT> PRAW/7.7.2.dev0 prawcore/2.3.0"
+          ]
+        },
+        "method": "POST",
+        "uri": "https://www.reddit.com/api/v1/access_token"
+      },
+      "response": {
+        "body": {
+          "encoding": "UTF-8",
+          "string": "{\"access_token\": \"<ACCESS_TOKEN>\", \"token_type\": \"bearer\", \"expires_in\": 86400, \"scope\": \"*\"}"
+        },
+        "headers": {
+          "Accept-Ranges": [
+            "bytes"
+          ],
+          "Cache-Control": [
+            "private, max-age=3600"
+          ],
+          "Connection": [
+            "close"
+          ],
+          "Content-Length": [
+            "812"
+          ],
+          "Date": [
+            "Thu, 09 Nov 2023 19:05:44 GMT"
+          ],
+          "NEL": [
+            "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 1.0, \"failure_fraction\": 1.0}"
+          ],
+          "Report-To": [
+            "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true,  \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}, {\"group\": \"w3-reporting-csp\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-csp.reddit.com/reports\" }]}"
+          ],
+          "Server": [
+            "snooserv"
+          ],
+          "Set-Cookie": [
+            "edgebucket=y9MIAbKPXg1UCtEUjS; Domain=reddit.com; Max-Age=63071999; Path=/;  secure"
+          ],
+          "Strict-Transport-Security": [
+            "max-age=31536000; includeSubdomains"
+          ],
+          "Vary": [
+            "accept-encoding"
+          ],
+          "Via": [
+            "1.1 varnish"
+          ],
+          "X-Content-Type-Options": [
+            "nosniff"
+          ],
+          "X-Frame-Options": [
+            "SAMEORIGIN"
+          ],
+          "X-XSS-Protection": [
+            "1; mode=block"
+          ],
+          "content-type": [
+            "application/json; charset=UTF-8"
+          ],
+          "x-moose": [
+            "majestic"
+          ],
+          "x-reddit-loid": [
+            "000000000njx4eypn1.2.1699556744224.Z0FBQUFBQmxUUzJJOWdUclR5d1hvZ0N5ak0xbUkyZmVYbVNadlFjYlFXVkRoaXgxeGo1cEFmSHNtcERLQ21JOUFQZkx1R1d1ZnFkTnRKSUducFNIUFhXdnZTVEVqTjJSTGdBNGdRRTREMVVZS1NvOTdwY29KLTdyeVYySWl0anJsS1FOcDFldWszS2M"
+          ]
+        },
+        "status": {
+          "code": 200,
+          "message": "OK"
+        },
+        "url": "https://www.reddit.com/api/v1/access_token"
+      }
+    },
+    {
+      "recorded_at": "2023-11-09T19:05:44",
+      "request": {
+        "body": {
+          "encoding": "utf-8",
+          "string": ""
+        },
+        "headers": {
+          "Accept": [
+            "*/*"
+          ],
+          "Accept-Encoding": [
+            "identity"
+          ],
+          "Authorization": [
+            "bearer <ACCESS_TOKEN>"
+          ],
+          "Connection": [
+            "keep-alive"
+          ],
+          "Cookie": [
+            "edgebucket=y9MIAbKPXg1UCtEUjS"
+          ],
+          "User-Agent": [
+            "<USER_AGENT> PRAW/7.7.2.dev0 prawcore/2.3.0"
+          ]
+        },
+        "method": "GET",
+        "uri": "https://www.reddit.com/r/redditdev/s/WNauetbiNG?raw_json=1"
+      },
+      "response": {
+        "body": {
+          "encoding": "utf-8",
+          "string": "<a href=\"https://www.reddit.com/r/redditdev/comments/2gmzqe/praw_https_enabled_praw_testing_needed/?share_id=oqqXWtvgcCuonkcpck8yD&amp;utm_content=1&amp;utm_medium=ios_app&amp;utm_name=ioscss&amp;utm_source=share&amp;utm_term=1\">Moved Permanently</a>.\n\n"
+        },
+        "headers": {
+          "Accept-Ranges": [
+            "bytes"
+          ],
+          "Cache-Control": [
+            "private, max-age=3600"
+          ],
+          "Connection": [
+            "keep-alive"
+          ],
+          "Content-Length": [
+            "253"
+          ],
+          "Date": [
+            "Thu, 09 Nov 2023 19:05:44 GMT"
+          ],
+          "NEL": [
+            "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 1.0, \"failure_fraction\": 1.0}"
+          ],
+          "Report-To": [
+            "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true,  \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}, {\"group\": \"w3-reporting-csp\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-csp.reddit.com/reports\" }]}"
+          ],
+          "Server": [
+            "snooserv"
+          ],
+          "Set-Cookie": [
+            "csv=2; Max-Age=63072000; Domain=.reddit.com; Path=/; Secure; SameSite=None"
+          ],
+          "Strict-Transport-Security": [
+            "max-age=31536000; includeSubdomains"
+          ],
+          "Vary": [
+            "Accept-Encoding"
+          ],
+          "Via": [
+            "1.1 varnish"
+          ],
+          "X-Content-Type-Options": [
+            "nosniff"
+          ],
+          "X-Frame-Options": [
+            "SAMEORIGIN"
+          ],
+          "X-XSS-Protection": [
+            "1; mode=block"
+          ],
+          "content-type": [
+            "text/html; charset=utf-8"
+          ],
+          "location": [
+            "https://www.reddit.com/r/redditdev/comments/2gmzqe/praw_https_enabled_praw_testing_needed/?share_id=oqqXWtvgcCuonkcpck8yD&utm_content=1&utm_medium=ios_app&utm_name=ioscss&utm_source=share&utm_term=1"
+          ]
+        },
+        "status": {
+          "code": 301,
+          "message": "Moved Permanently"
+        },
+        "url": "https://www.reddit.com/r/redditdev/s/WNauetbiNG?raw_json=1"
+      }
+    }
+  ],
+  "recorded_with": "betamax/0.8.1"
+}
diff --git a/tests/integration/cassettes/TestSubmission.test_resolve_from_share_url__invalid_url.json b/tests/integration/cassettes/TestSubmission.test_resolve_from_share_url__invalid_url.json
new file mode 100644
--- /dev/null
+++ b/tests/integration/cassettes/TestSubmission.test_resolve_from_share_url__invalid_url.json
@@ -0,0 +1,195 @@
+{
+  "http_interactions": [
+    {
+      "recorded_at": "2023-11-09T19:06:53",
+      "request": {
+        "body": {
+          "encoding": "utf-8",
+          "string": "grant_type=client_credentials"
+        },
+        "headers": {
+          "Accept": [
+            "*/*"
+          ],
+          "Accept-Encoding": [
+            "identity"
+          ],
+          "Authorization": [
+            "Basic <BASIC_AUTH>"
+          ],
+          "Connection": [
+            "close"
+          ],
+          "Content-Length": [
+            "29"
+          ],
+          "Content-Type": [
+            "application/x-www-form-urlencoded"
+          ],
+          "User-Agent": [
+            "<USER_AGENT> PRAW/7.7.2.dev0 prawcore/2.3.0"
+          ]
+        },
+        "method": "POST",
+        "uri": "https://www.reddit.com/api/v1/access_token"
+      },
+      "response": {
+        "body": {
+          "encoding": "UTF-8",
+          "string": "{\"access_token\": \"<ACCESS_TOKEN>\", \"token_type\": \"bearer\", \"expires_in\": 86400, \"scope\": \"*\"}"
+        },
+        "headers": {
+          "Accept-Ranges": [
+            "bytes"
+          ],
+          "Cache-Control": [
+            "private, max-age=3600"
+          ],
+          "Connection": [
+            "close"
+          ],
+          "Content-Length": [
+            "812"
+          ],
+          "Date": [
+            "Thu, 09 Nov 2023 19:06:54 GMT"
+          ],
+          "NEL": [
+            "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 1.0, \"failure_fraction\": 1.0}"
+          ],
+          "Report-To": [
+            "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true,  \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}, {\"group\": \"w3-reporting-csp\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-csp.reddit.com/reports\" }]}"
+          ],
+          "Server": [
+            "snooserv"
+          ],
+          "Set-Cookie": [
+            "edgebucket=YuaQkSYe7CLjd5kM7H; Domain=reddit.com; Max-Age=63071999; Path=/;  secure"
+          ],
+          "Strict-Transport-Security": [
+            "max-age=31536000; includeSubdomains"
+          ],
+          "Vary": [
+            "accept-encoding"
+          ],
+          "Via": [
+            "1.1 varnish"
+          ],
+          "X-Content-Type-Options": [
+            "nosniff"
+          ],
+          "X-Frame-Options": [
+            "SAMEORIGIN"
+          ],
+          "X-XSS-Protection": [
+            "1; mode=block"
+          ],
+          "content-type": [
+            "application/json; charset=UTF-8"
+          ],
+          "x-moose": [
+            "majestic"
+          ],
+          "x-reddit-loid": [
+            "000000000njx6srhai.2.1699556814022.Z0FBQUFBQmxUUzNPRVdfX0p6V090eVlJYURGUFNORV9mODZpZWRRSmZybjV2ZjgwenZYNEpPQTN3VEdGQlRZbjhLM1I3clR4VkhkNkthQXY1dVdjeVZmVXB3NmRsM1RNOThUWlRldzQtY2JwV29WNTJIbktrT1lTMEpTMTEyelZocnNWM1JmNExBRGQ"
+          ]
+        },
+        "status": {
+          "code": 200,
+          "message": "OK"
+        },
+        "url": "https://www.reddit.com/api/v1/access_token"
+      }
+    },
+    {
+      "recorded_at": "2023-11-09T19:06:53",
+      "request": {
+        "body": {
+          "encoding": "utf-8",
+          "string": ""
+        },
+        "headers": {
+          "Accept": [
+            "*/*"
+          ],
+          "Accept-Encoding": [
+            "identity"
+          ],
+          "Authorization": [
+            "bearer <ACCESS_TOKEN>"
+          ],
+          "Connection": [
+            "keep-alive"
+          ],
+          "Cookie": [
+            "edgebucket=YuaQkSYe7CLjd5kM7H"
+          ],
+          "User-Agent": [
+            "<USER_AGENT> PRAW/7.7.2.dev0 prawcore/2.3.0"
+          ]
+        },
+        "method": "GET",
+        "uri": "https://reddit.com/r/space/s/?raw_json=1"
+      },
+      "response": {
+        "body": {
+          "encoding": null,
+          "string": ""
+        },
+        "headers": {
+          "Accept-Ranges": [
+            "bytes"
+          ],
+          "Cache-Control": [
+            "private, max-age=3600"
+          ],
+          "Connection": [
+            "close"
+          ],
+          "Content-Length": [
+            "0"
+          ],
+          "Date": [
+            "Thu, 09 Nov 2023 19:06:54 GMT"
+          ],
+          "Location": [
+            "https://www.reddit.com/r/space/s/?raw_json=1"
+          ],
+          "NEL": [
+            "{\"report_to\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": false, \"success_fraction\": 1.0, \"failure_fraction\": 1.0}"
+          ],
+          "Report-To": [
+            "{\"group\": \"w3-reporting-nel\", \"max_age\": 14400, \"include_subdomains\": true,  \"endpoints\": [{ \"url\": \"https://w3-reporting-nel.reddit.com/reports\" }]}, {\"group\": \"w3-reporting\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting.reddit.com/reports\" }]}, {\"group\": \"w3-reporting-csp\", \"max_age\": 14400, \"include_subdomains\": true, \"endpoints\": [{ \"url\": \"https://w3-reporting-csp.reddit.com/reports\" }]}"
+          ],
+          "Retry-After": [
+            "0"
+          ],
+          "Server": [
+            "snooserv"
+          ],
+          "Strict-Transport-Security": [
+            "max-age=31536000; includeSubdomains; preload"
+          ],
+          "Via": [
+            "1.1 varnish"
+          ],
+          "X-Content-Type-Options": [
+            "nosniff"
+          ],
+          "X-Frame-Options": [
+            "SAMEORIGIN"
+          ],
+          "X-XSS-Protection": [
+            "1; mode=block"
+          ]
+        },
+        "status": {
+          "code": 301,
+          "message": "Moved Permanently"
+        },
+        "url": "https://reddit.com/r/space/s/?raw_json=1"
+      }
+    }
+  ],
+  "recorded_with": "betamax/0.8.1"
+}
diff --git a/tests/integration/models/reddit/test_comment.py b/tests/integration/models/reddit/test_comment.py
--- a/tests/integration/models/reddit/test_comment.py
+++ b/tests/integration/models/reddit/test_comment.py
@@ -217,6 +217,15 @@ def test_report(self, reddit):
         reddit.read_only = False
         Comment(reddit, "d0335z3").report("custom")
 
+    def test_resolve_from_share_url(self, reddit):
+        url = "https://www.reddit.com/r/redditdev/s/nGnQE1QkLC"
+        assert reddit.comment(url=url) == "cklhv0f", url
+
+    def test_resolve_from_share_url__invalid_url(self, reddit):
+        url = "https://www.reddit.com/r/redditdev/s/WNauetbiNG"
+        with pytest.raises(ClientException):
+            reddit.comment(url=url)
+
     def test_save(self, reddit):
         reddit.read_only = False
         Comment(reddit, "d1680wu").save(category="foo")
diff --git a/tests/integration/models/reddit/test_submission.py b/tests/integration/models/reddit/test_submission.py
--- a/tests/integration/models/reddit/test_submission.py
+++ b/tests/integration/models/reddit/test_submission.py
@@ -1,6 +1,6 @@
 import pytest
 
-from praw.exceptions import RedditAPIException
+from praw.exceptions import RedditAPIException, ClientException
 from praw.models import Comment, InlineGif, InlineImage, InlineVideo, Submission
 
 from ... import IntegrationTest
@@ -276,6 +276,15 @@ def test_report(self, reddit):
         reddit.read_only = False
         Submission(reddit, "4b536h").report("praw")
 
+    def test_resolve_from_share_url(self, reddit):
+        url = "https://www.reddit.com/r/redditdev/s/WNauetbiNG"
+        assert reddit.submission(url=url) == "2gmzqe", url
+
+    def test_resolve_from_share_url__invalid_url(self, reddit):
+        url = "https://reddit.com/r/space/s/"
+        with pytest.raises(ClientException):
+            reddit.submission(url=url)
+
     def test_save(self, reddit):
         reddit.read_only = False
         Submission(reddit, "4b536p").save()