Skip to content

[reCreate] edit function that it'll show button only if url is able to fetch #3

@SGI-CAPP-AT2

Description

@SGI-CAPP-AT2

IMG_20221004_084828
Should get valid url
Targets

  1. const isValidUrl = urlString=> {
    var urlPattern = new RegExp('^(https?:\\/\\/)?'+ // validate protocol
    '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // validate domain name
    '((\\d{1,3}\\.){3}\\d{1,3}))'+ // validate OR ip (v4) address
    '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // validate port and path
    '(\\?[;&a-z\\d%_.~+=-]*)?'+ // validate query string
    '(\\#[-a-z\\d_]*)?$','i'); // validate fragment locator
    return !!urlPattern.test(urlString);
    }
  2. https://github.com/SGI-CAPP-AT2/code-highlight-n-print/blob/main/tool/ss/app.js#L54-L67
  • create event listener url-validated
  • dispatch on url validated successfully
  • while dispatch pass ev.isValid:bool
  • show fetch url button only if ev.isValid:bool is true

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions