ts-utils
  • Getting Started
  • Contributing
  • Testing
  • Functions
    • Array Methods
      • isArr
      • isArrEmpty
      • pushUniqueValue
      • pushOrUpdate
    • Date Methods
      • toNow
      • formatDate
      • fromNow
    • Number Methods
      • toFixed
      • parseNumber
      • parseFormat
      • addUnit
      • addSeparators
      • formatNumber
      • ensureNumber
      • numberEmptyState
    • Object Methods
      • parseJSON
      • deepClone
      • parseNumValues
      • removeEmptyKeys
      • sanitizeQuery
      • removeKeys
      • renameKey
      • renameKeys
      • sortByKeyLength
      • querylize
      • parseNumericObj
      • reserveKeys
      • hasKeysAndValues
    • String Methods
      • randomStr
      • toUpperCase
      • toLowerCase
      • toFullUrl
      • initials
      • generateUuid
Powered by GitBook
On this page
  • toFullUrl(url, options)
  • Arguments
  • Returns
  • Example
  • Usage
  • Notes

Was this helpful?

  1. Functions
  2. String Methods

toFullUrl

toFullUrl(url, options)

Converts a partial URL to a full URL by adding missing components like protocol and domain. This function enhances partial URLs to complete URLs by ensuring all necessary components are included.

Arguments

  • url (string): The partial URL to convert to a full URL.

  • options (Record<string, any> | undefined): Additional options for customizing the URL conversion. Defaults to undefined.

Returns

  • string: The full URL with all necessary components added.

Example

typescript
import { toFullUrl } from 'check-engineering/ts-utils';

const partialUrl = "example.com";
const fullUrl = toFullUrl(partialUrl); // => "https://example.com"

Usage

typescript
import { toFullUrl } from 'check-engineering/ts-utils';

const partialUrl = "subdomain.example.com";
const customOptions = { protocol: "http://" };
const customizedUrl = toFullUrl(partialUrl, customOptions); // => "http://subdomain.example.com"

Notes

  • The toFullUrl function transforms partial URLs into complete URLs by adding missing components like protocol and domain.

  • It provides flexibility with additional options to customize the URL conversion process.

  • This function is useful for ensuring that URLs are properly formatted and complete for use in web applications.

PrevioustoLowerCaseNextinitials

Last updated 11 months ago

Was this helpful?