[PR #271] [MERGED] clean up url handling #10991

Closed
opened 2026-05-02 22:42:01 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/imputnet/cobalt/pull/271
Author: @dumbmoron
Created: 12/12/2023
Status: Merged
Merged: 12/25/2023
Merged by: @wukko

Base: 7.8Head: cleanup-url-handling


📝 Commits (10+)

  • dd563eb api: rework url parsing
  • 2e1eb1b api: rename hostOverrides to 'url'
  • 149c16a url: make youtu.be alias rule more lax
  • f9feaa4 tumblr: stricter subdomain parsing
  • c458423 match: light cleanup
  • 3056624 servicesConfig: set up subdomains
  • 6623605 url: return host instead of bool for success
  • 30c9652 url: typo
  • 81e68c3 processing: pass URL object instead of string
  • 34d8333 tumblr: render error template for broken links

📊 Changes

12 files changed (+161 additions, -112 deletions)

View changed files

📝 package.json (+1 -0)
📝 src/core/api.js (+1 -1)
📝 src/front/cobalt.js (+2 -2)
📝 src/modules/api.js (+17 -20)
📝 src/modules/config.js (+9 -0)
src/modules/processing/hostOverrides.js (+0 -48)
📝 src/modules/processing/match.js (+11 -6)
📝 src/modules/processing/services/soundcloud.js (+4 -3)
📝 src/modules/processing/services/tumblr.js (+8 -3)
📝 src/modules/processing/servicesConfig.json (+7 -0)
src/modules/processing/url.js (+96 -0)
📝 src/modules/sub/utils.js (+5 -29)

📄 Description

fixes:

improvements:

  • url patterns are pre-compiled instead of being compiled for every request
  • aliases are computed in a safe manner using the URL object where possible
  • frontend no longer mangles the url when sending to api
  • api is now more tolerant to urls with whitespace around them (e.g. https://x.com/... works) - useful since pasting urls with leading/trailing spaces by accident happens quite often

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/imputnet/cobalt/pull/271 **Author:** [@dumbmoron](https://github.com/dumbmoron) **Created:** 12/12/2023 **Status:** ✅ Merged **Merged:** 12/25/2023 **Merged by:** [@wukko](https://github.com/wukko) **Base:** `7.8` ← **Head:** `cleanup-url-handling` --- ### 📝 Commits (10+) - [`dd563eb`](https://github.com/imputnet/cobalt/commit/dd563eb752f0883e295b6042db3387f802d5871f) api: rework url parsing - [`2e1eb1b`](https://github.com/imputnet/cobalt/commit/2e1eb1b864b071f976777105b758729c600f47d1) api: rename hostOverrides to 'url' - [`149c16a`](https://github.com/imputnet/cobalt/commit/149c16abbb7dbbdceaf3e1ed138608a5f55c435f) url: make youtu.be alias rule more lax - [`f9feaa4`](https://github.com/imputnet/cobalt/commit/f9feaa41ce77b14c3782ea64acc74361780f6853) tumblr: stricter subdomain parsing - [`c458423`](https://github.com/imputnet/cobalt/commit/c458423e03153bbb4d40cbb894128f8324429bd5) match: light cleanup - [`3056624`](https://github.com/imputnet/cobalt/commit/3056624b3d574c2ef8d2bcff7005cba46041c095) servicesConfig: set up subdomains - [`6623605`](https://github.com/imputnet/cobalt/commit/662360509c4c55b3431db8bbd3c82f2f5a927ba2) url: return host instead of bool for success - [`30c9652`](https://github.com/imputnet/cobalt/commit/30c9652b6e8803509cc7d563113214bb583a793b) url: typo - [`81e68c3`](https://github.com/imputnet/cobalt/commit/81e68c37f500218ce79793981678941ee97879b6) processing: pass URL object instead of string - [`34d8333`](https://github.com/imputnet/cobalt/commit/34d8333d726db624fdb1fad21ab7a00527e7791e) tumblr: render error template for broken links ### 📊 Changes **12 files changed** (+161 additions, -112 deletions) <details> <summary>View changed files</summary> 📝 `package.json` (+1 -0) 📝 `src/core/api.js` (+1 -1) 📝 `src/front/cobalt.js` (+2 -2) 📝 `src/modules/api.js` (+17 -20) 📝 `src/modules/config.js` (+9 -0) ➖ `src/modules/processing/hostOverrides.js` (+0 -48) 📝 `src/modules/processing/match.js` (+11 -6) 📝 `src/modules/processing/services/soundcloud.js` (+4 -3) 📝 `src/modules/processing/services/tumblr.js` (+8 -3) 📝 `src/modules/processing/servicesConfig.json` (+7 -0) ➕ `src/modules/processing/url.js` (+96 -0) 📝 `src/modules/sub/utils.js` (+5 -29) </details> ### 📄 Description fixes: - tlds are now parsed and validated correctly (e.g. "pinterest.co.uk" works now) - fixes #264 - urls with paths containing dots now work ([example](https://www.instagram.com/stories/hoseobiiiiiii._.0410/3257661247380116688)) - fixes #275 - query parameters are now parsed and handled correctly - subdomains and tlds are properly (& mostly strictly) validated ([examples of some urls that are no longer considered valid](https://gist.github.com/dumbmoron/1e667f42463820fcce299b910c777dd5)) improvements: - url patterns are pre-compiled instead of being compiled for every request - aliases are computed in a safe manner using the URL object where possible - frontend no longer mangles the url when sending to api - api is now more tolerant to urls with whitespace around them (e.g. ` https://x.com/... ` works) - useful since pasting urls with leading/trailing spaces by accident happens quite often --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-02 22:42:01 -05:00
Sign in to join this conversation.