Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catalog relative url now are relative to the catalog requests #1617

Merged
merged 1 commit into from
Mar 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions web/client/selectors/__tests__/cswtocatalog-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const sampleCSWRecord = {
TYPE_NAME: "DC_1_1.URI",
protocol: "image/png",
name: "thumbnail",
value: "img.jpg"
value: "http://sample.com/img.jpg"
}]
}
};
Expand All @@ -57,7 +57,7 @@ const sampleCSWRecord2 = {
value: "http://wms.sample.service:80/geoserver/wms?SERVICE=WMS&layers=workspace:layername"
}, {
scheme: "WWW:LINK-1.0-http--image-thumbnail",
value: "img.jpg"
value: "http://sample.com/img.jpg"
}]
}
};
Expand All @@ -66,7 +66,7 @@ const sampleRecord = {
title: "sample title",
tags: ["subject1", "subject2"],
description: "sample abstract",
thumbnail: "http:sample.com/img.jpg",
thumbnail: "http://sample.com/img.jpg",
boundingBox: {
extent: [10.686,
44.931,
Expand All @@ -87,7 +87,7 @@ describe('Test csw to catalog selector', () => {
const testState = {
catalog: {
searchOptions: {
catalogURL: "http:sample.com"
catalogURL: "http://sample.com"
},
result: {
records: [sampleCSWRecord],
Expand All @@ -106,7 +106,7 @@ describe('Test csw to catalog selector', () => {
const testState = {
catalog: {
searchOptions: {
catalogURL: "http:sample.com"
catalogURL: "http://sample.com"
},
result: {
records: [sampleCSWRecord2],
Expand Down
10 changes: 7 additions & 3 deletions web/client/selectors/cswtocatalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ const assign = require('object-assign');
const {head} = require('lodash');
const urlUtil = require('url');


const getBaseCatalogUrl = (url) => {
return url && url.substring(0, url.lastIndexOf("/"));
};
/**
* Parses a csw object and returns an object with a common form.
* records:
Expand Down Expand Up @@ -57,7 +61,7 @@ const cswToCatalogSelector = (catalog) => {
}).forEach((reference) => {
// a get capabilities reference should be absolute and filter by the layer name
let referenceUrl = reference.value.indexOf("http") === 0 ? reference.value
: searchOptions.catalogURL + "/" + reference.value;
: getBaseCatalogUrl(searchOptions.catalogURL || searchOptions.url) + reference.value;
// add the references to the final list
references.push({
type: reference.scheme,
Expand All @@ -79,7 +83,7 @@ const cswToCatalogSelector = (catalog) => {
if (wms) {
let absolute = (wms.value.indexOf("http") === 0);
if (!absolute) {
assign({}, wms, {value: searchOptions.catalogURL + "/" + wms.value} );
assign({}, wms, {value: getBaseCatalogUrl(searchOptions.catalogURL || searchOptions.url) + wms.value} );
}
let wmsReference = {
type: wms.protocol || wms.scheme,
Expand All @@ -93,7 +97,7 @@ const cswToCatalogSelector = (catalog) => {
if (thumbURL) {
let absolute = (thumbURL.indexOf("http") === 0);
if (!absolute) {
thumbURL = searchOptions.catalogURL + "/" + thumbURL;
thumbURL = getBaseCatalogUrl(searchOptions.catalogURL || searchOptions.url) + thumbURL;
}
}
// create the references array (now only wms is supported)
Expand Down