• Validates and transforms a submitted job ID input into a URL if applicable.

    Parameters

    • data: string

      The input string to validate and potentially transform.

    Returns string

    • The transformed URL if the input is a valid job ID, otherwise the original input.

    validateSubmittedJobIdInput

    Checks if the input is a job ID by:

    • Ensuring it does not start with 'http', contain '/', or './' (to exclude URLs or paths).
    • Validating it against jobIdDefaults using validateJobId. If it’s a valid job ID, returns the corresponding JDispatcher JSON URL via getJdispatcherJsonURL. Otherwise, returns the input unchanged.
    • JobIdValidable - Interface defining job ID validation constraints.
    • validateJobId - Function used to validate the job ID.
    • getJdispatcherJsonURL - Function used to generate the JDispatcher URL.
    // Valid job ID
    const result = validateSubmittedJobIdInput('ncbiblast-I20200317-103136-0485-5599422-np2');
    console.log(result);
    // Outputs: "https://wwwdev.ebi.ac.uk/Tools/services/rest/ncbiblast/result/ncbiblast-I20200317-103136-0485-5599422-np2/json"

    // URL or invalid input (returned unchanged)
    console.log(validateSubmittedJobIdInput('https://example.com/data.json'));
    // Outputs: "https://example.com/data.json"

    console.log(validateSubmittedJobIdInput('invalid'));
    // Outputs: "invalid"