Skip to content

Commit

Permalink
Fix/no workflow found (#211)
Browse files Browse the repository at this point in the history
* removing encodeURIComponent to avoid double decoding URL

* locking all versions so they dont auto fetch latest minor versions

* revert package file fix

* fixed timeline dependency to use latest version. Current version is depricated. see issue #192

* fixing failing integration test

* only escape forward slash

* adding console logs to help debugging

* moving logic into helper and fixing at router level.

* adding unit tests

* removing escaped runId as this is generated from server and is gauranteed to be a UUID
  • Loading branch information
just-at-uber authored Oct 23, 2020
1 parent a933099 commit 31f8c8a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 8 deletions.
2 changes: 2 additions & 0 deletions client/helpers/get-escaped-forward-slash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const getEscapedForwardSlash = (str) => str.replace(/\//g, '%2F');
export default getEscapedForwardSlash;
27 changes: 27 additions & 0 deletions client/helpers/get-escaped-forward-slash.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import getEscapedForwardSlash from './get-escaped-forward-slash';

describe('getEscapedForwardSlash', () => {
it('should escape one forward slash and convert to %2F.', () => {
const input = '/';
const output = getEscapedForwardSlash(input);
expect(output).toEqual('%2F');
});

it('should escape many forward slashes and convert each to %2F.', () => {
const input = '///';
const output = getEscapedForwardSlash(input);
expect(output).toEqual('%2F%2F%2F');
});

it('should convert forward slashes in a string containing other characters with forward slashes.', () => {
const input = 'hello/world';
const output = getEscapedForwardSlash(input);
expect(output).toEqual('hello%2Fworld');
});

it('should not do anything if string does not contain forward slash.', () => {
const input = 'hello\world';
const output = getEscapedForwardSlash(input);
expect(output).toEqual('hello\world');
});
});
1 change: 1 addition & 0 deletions client/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export { default as getEnvironment } from './get-environment';
export { default as getEnvironmentList } from './get-environment-list';
export { default as getEnvironmentLocation } from './get-environment-location';
export { default as getErrorMessage } from './get-error-message';
export { default as getEscapedForwardSlash } from './get-escaped-forward-slash';
export { default as getJsonStringObject } from './get-json-string-object';
export { default as getKeyValuePairs } from './get-key-value-pairs';
export { default as getLatestNewsItems } from './get-latest-news-items';
Expand Down
8 changes: 4 additions & 4 deletions client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import WorkflowList from './routes/domain/workflow-list';
import WorkflowSummary from './routes/workflow/summary';
import WorkflowTabs from './routes/workflow';

import { http, injectMomentDurationFormat, jsonTryParse } from '~helpers';
import { getEscapedForwardSlash, http, injectMomentDurationFormat, jsonTryParse } from '~helpers';

const routeOpts = {
mode: 'history',
Expand Down Expand Up @@ -138,7 +138,7 @@ const routeOpts = {
props: ({ params }) => ({
domain: params.domain,
runId: params.runId,
workflowId: params.workflowId,
workflowId: getEscapedForwardSlash(params.workflowId),
}),
children: [
{
Expand All @@ -150,7 +150,7 @@ const routeOpts = {
props: {
summary: ({ params }) => ({
runId: params.runId,
workflowId: params.workflowId,
workflowId: getEscapedForwardSlash(params.workflowId),
}),
},
},
Expand All @@ -167,7 +167,7 @@ const routeOpts = {
format: query.format || 'grid',
runId: params.runId,
showGraph: Boolean(query.showGraph) === true,
workflowId: params.workflowId,
workflowId: getEscapedForwardSlash(params.workflowId),
}),
},
},
Expand Down
5 changes: 1 addition & 4 deletions client/routes/workflow/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ export default {
computed: {
baseAPIURL() {
const { domain, workflowId, runId } = this;
return `/api/domains/${domain}/workflows/${encodeURIComponent(
workflowId
)}/${encodeURIComponent(runId)}`;
return `/api/domains/${domain}/workflows/${workflowId}/${runId}`;
},
historyEvents() {
const {
Expand Down

0 comments on commit 31f8c8a

Please sign in to comment.