Skip to content
This repository has been archived by the owner on Jul 13, 2022. It is now read-only.

Relative path not resolved without a trailing slash in the pathname #8

Open
nanndoj opened this issue Nov 24, 2019 · 0 comments · May be fixed by #9
Open

Relative path not resolved without a trailing slash in the pathname #8

nanndoj opened this issue Nov 24, 2019 · 0 comments · May be fixed by #9

Comments

@nanndoj
Copy link

nanndoj commented Nov 24, 2019

I have three x-road instances configured to the same server under different pathnames

https://mysite.com/instance-prod
https://mysite.com/instance-qa
https://mysite.com/instance-dev

But because we use relative paths in jQuery's $.ajax function, it tries to resolve to the same level as the instance pathname if we don't add a trailing space on the url. It leads to false incident alarms when the users forget to provide the trailing slashes

Expected Behavior

The application should load when accessing https://mysite.com/instance-prod in the same way as https://mysite.com/instance-prod/

Actual behaviour

When accessing https://mysite.com/instance-prod, the ajax function tries to load

https://mysite.com/get_incident_table_initialization_data

instead of https://mysite.com/instance-prod/get_incident_table_initialization_data

Possible Solution

Use always the full path when issuing all the ajax requests:

   function initialize_incident_table(table_id, serverside_url, service_call_toggle_id, new_constraint_column_id, alert_id) {
    $.ajax({
        url: basePath + "get_incident_table_initialization_data",
        method: 'GET',
        data: {table_id: JSON.stringify(table_id)},
        ...

or add the trailing slash to the pathname, if not present, during the initial load (index.js)

$(document).ready(function() {
    if(!location.pathname.endsWith('/')) {
        location.pathname = location.pathname + '/';
    }
});
@nanndoj nanndoj changed the title Relative paths not being resolved without a trailing slash on the pathname Relative path not resolved without a trailing slash in the pathname Nov 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant