Options
All
  • Public
  • Public/Protected
  • All
Menu

Module source/url

Index

Variables

Variables

Const url

url: { expression: () => RegExp; getDomain: (str: string) => string[]; isValid: (str: string) => boolean; remove: (str: string) => string; retrieve: (str: string) => string[]; swap: (str: string, other: string) => string } = ...

Type declaration

  • expression: () => RegExp
      • (): RegExp
      • Returns RegExp for testing URLs

        Returns RegExp

  • getDomain: (str: string) => string[]
      • (str: string): string[]
      • Takes url string, tries to return just the domain

        Basic usage example:

        const url = require('stringman').url; // or `import {url} from 'stringman'`;
        const domain = url.getDomain('https://www.google.com/test');
        console.log(domain); // '[google.com]'
        

        Parameters

        • str: string

        Returns string[]

  • isValid: (str: string) => boolean
      • (str: string): boolean
      • Takes a string and returns whether string is a valid URL as a boolean

        Basic usage example:

        const url = require('stringman').url; // or `import {url} from 'stringman'`;
        const valid = url.isValid('https://joeyg.me');
        const invalid = url.isValid('https/joeyg.me');
        console.log(valid); // true
        console.log(invalid); // false
        

        Parameters

        • str: string

        Returns boolean

  • remove: (str: string) => string
      • (str: string): string
      • Takes string, removes any URLs, trims, and returns string

        Basic usage example:

        const url = require('stringman').url; // or `import {url} from 'stringman'`;
        const removed = url.remove('the url to my portfolio is https://joeyg.me');
        console.log(removed); // 'the url to my portfolio is'
        

        Parameters

        • str: string

        Returns string

  • retrieve: (str: string) => string[]
      • (str: string): string[]
      • Takes string and returns any matches for a valid URL from the string

        Basic usage example:

        const url = require('stringman').url; // or `import {url} from 'stringman'`;
        const justUrl = url.retrieve('the url to my portfolio is https://joeyg.me');
        console.log(justUrl); // 'https://joeyg.me'
        

        Parameters

        • str: string

        Returns string[]

  • swap: (str: string, other: string) => string
      • (str: string, other: string): string
      • takes a string with a url and a second string, swaps any urls in the first string with the second string, and returns the result

        Basic usage example:

        const url = require('stringman').url; // or `import {url} from 'stringman'`;
        const swapped = url.swap('this is a test for https://test.com', 'http://www.fakesite.org');
        console.log(swapped); // 'this is a test for http://www.fakesite.org'
        

        Parameters

        • str: string
        • other: string

        Returns string

Generated using TypeDoc