ec-jrc / re3gistry

Re3gistry is a reusable open source solution for managing and sharing ‘reference codes’, ensuring semantic interoperability across organisations.
European Union Public License 1.2
29 stars 21 forks source link

Error occurs when a register's name contains 2 dots #61

Closed kauk closed 2 years ago

kauk commented 3 years ago

An error occurs in the Re³gistry "example service frontend" if a register with 2 dots in its name is shown. In this case the Re³gistry tries to read a language code from the URL. Loading the website fails if this is not a valid language code.

The problem is this code (and the following lines): https://github.com/ec-jrc/re3gistry/blob/4d3b5f5ed4186ed97d05251307b466af6e07f9c7/dist/webapp/public_html/js/app_common.js#L151 As soon as there are 2 dots in the URL after the last /, the first 2 chars between these dots are read as a language code.

emanuelaepure10 commented 2 years ago

Hi @kauk

I think that just substituting the code you have suggested

 if (urlCheck.length === 3) {

// Getting the language specified in the URL and updating the
// global variable
        let tmpLangIndex = tmpUrl.indexOf(val_dot);
        let tmpLang = tmpUrl.substring(tmpLangIndex + 1, tmpLangIndex + 3);
        languageFromUrl = tmpLang;
        // Getting the URI to be passed to the data service and updating the
        // global variable
        i = currentUrl.lastIndexOf(val_dot) - 3;
        uriFromUrl = currentUrl.substring(0, i);
    } else {

// Passing the current URL as the URI to be passed to the data service
        languageFromUrl = val_emptyString;
        uriFromUrl = currentUrl;
    }

with simply

   languageFromUrl = val_emptyString;
        uriFromUrl = currentUrl;

doesnt give anymore the error. Would you try to see if you still get the error?

Thank you

kauk commented 2 years ago

Thank you for looking into this issue, @emanuelaepure10. Unfortunately, I cannot try your suggestion as I am not working with the Re³gistry anymore. I will try to find someone who can verify your suggestion.

unaibrrgn commented 2 years ago

The solution given has been tested and works correctly.

Thank you!