{"record":{"id":"7776e588048e8ce2","repo":"mihomo-party-org/clash-party","slug":"plugin-url-must-not-contain-a-fragment","errorCode":null,"errorMessage":"Plugin URL must not contain a fragment","messagePattern":"Plugin URL must not contain a fragment","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main/resolve/plugin/remote.ts","lineNumber":15,"sourceCode":"import { getAppConfig } from '../../config/app'\nimport { MAX_PLUGIN_FILE_BYTES } from './constants'\nimport { requestOnce } from './http-client'\nimport { createGuardedLookup, isForbiddenHost } from './net-guard'\n\nfunction parseDownloadUrl(url: string): URL {\n  let parsed: URL\n  try {\n    parsed = new URL(url)\n  } catch {\n    throw new Error('Invalid plugin URL')\n  }\n  if (parsed.protocol !== 'https:') throw new Error('Plugin URL must use https')\n  if (parsed.username || parsed.password) throw new Error('Plugin URL must not contain userinfo')\n  if (parsed.hash) throw new Error('Plugin URL must not contain a fragment')\n  if (isForbiddenHost(parsed.hostname)) throw new Error('Plugin URL must use a public host')\n  return parsed\n}\n\nexport async function fetchRemotePlugin(url: string): Promise<string> {\n  const parsed = parseDownloadUrl(url)\n  const { subscriptionTimeout = 30000, pluginUseProxy } = await getAppConfig()\n  let proxy: { host: string; port: number } | undefined\n  if (pluginUseProxy) {\n    const { getControledMihomoConfig } = await import('../../config/controledMihomo')\n    const { 'mixed-port': port = 7890 } = await getControledMihomoConfig()\n    proxy = { host: '127.0.0.1', port }\n  }\n\n  const response = await requestOnce(parsed.toString(), {\n    method: 'GET',\n    headers: { Accept: 'application/json, application/octet-stream' },\n    timeout: subscriptionTimeout,","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/mihomo-party-org/clash-party/blob/911e090537acdf7c50bee1c3aebecc2ef119a8b5/src/main/resolve/plugin/remote.ts#L1-L33","documentation":"parseDownloadUrl rejects URLs containing a fragment (#...) because fragments are client-side pointers and make download identity/caching ambiguous. A URL with a # part throws 'Plugin URL must not contain a fragment'.","triggerScenarios":"Passing a download URL that ends with or contains '#...' — e.g. a documentation link copied with an anchor (https://example.com/plugin.yaml#install), or a template string where a placeholder got glued to a '#id'.","commonSituations":"Copying a link from a rendered page that includes a section anchor; appending cache-busting '#v2' instead of a query param; string concatenation bugs leaving a '#fragment' suffix.","solutions":["Strip the '#...' portion of the URL before calling.","If you need a version/cache-buster, use a query string (?v=2) if the server supports it — but prefer the canonical bare file URL.","Copy the direct file link from the source rather than an anchored page link."],"exampleFix":"// before\nawait fetchRemotePlugin('https://example.com/plugin.yaml#install')\n// after\nawait fetchRemotePlugin('https://example.com/plugin.yaml')","handlingStrategy":"validation","validationCode":"const u = new URL(input)\nif (u.hash) throw new Error('strip the #fragment from the download URL')","typeGuard":"const hasNoFragment = (s: string): boolean => {\n  try { return !new URL(s).hash } catch { return false }\n}","tryCatchPattern":"try {\n  await fetchRemotePlugin(input)\n} catch (e) {\n  if (e.message === 'Plugin URL must not contain a fragment') {\n    showUrlInputError('Remove the #... part of the URL')\n  } else throw e\n}","preventionTips":["Strip u.hash before calling when normalizing URLs","Copy direct file links, not anchored page links","Use query params, not fragments, for cache-busting","Validate stored URLs once at config time"],"tags":["url","validation","fragment","plugin"],"backgroundTag":"invalid-url","analyzedSha":"911e090537acdf7c50bee1c3aebecc2ef119a8b5","analyzedAt":"2026-08-30T13:00:49.174Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}