Skip to main content
The no-invalid-fetch-url rule validates that the first argument of hubspot.fetch() is a fully-qualified HTTPS URL.

Rule details

hubspot.fetch() requires a fully-qualified HTTPS URL. Relative paths and non-HTTPS URLs fail at runtime. This rule validates that the URL:
  1. Contains no leading or trailing whitespace.
  2. Is absolute, not a relative path.
  3. Uses the https:// protocol.
The rule checks the first argument when its value can be determined from the code, including string literals, template literals, string concatenation, and variables declared with const in the same file. For template literals and concatenation, the rule checks the text before the first dynamic value. Values that are only known at runtime are not validated by this rule, such as function parameters, imported values, let and var variables, and values that start with a dynamic part. Calls to fetch() on objects other than hubspot are also ignored. Native fetch() calls are reported by the no-native-http rule.

Examples

Relative URLs

Invalid: relative URL path:
Instead use the full URL:

Invalid protocols

Invalid: unsupported URL protocol:
Use the https:// protocol instead:

Whitespace in URLs

Invalid: extra space around the URL:
Remove the whitespace:

Template literals and variables

The rule checks the known start of a template literal or concatenated string, and the value of a const variable:
Start the URL with an HTTPS URL instead:

Dynamic values

Dynamic values are not validated by this rule:
Last modified on November 23, 2026