Skip to content

Commit

Permalink
chore(sdk): hedge against trailing slash on scheduler url
Browse files Browse the repository at this point in the history
  • Loading branch information
TillaTheHun0 committed Dec 19, 2023
1 parent b1308fd commit 8cf6ae2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
14 changes: 7 additions & 7 deletions sdk/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"test:integration": "cd ./test/e2e && npm test"
},
"dependencies": {
"@permaweb/ao-scheduler-utils": "~0.0.3",
"@permaweb/ao-scheduler-utils": "~0.0.4",
"buffer": "^6.0.3",
"debug": "^4.3.4",
"hyper-async": "^1.1.2",
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/lib/message/verify-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Rejected, Resolved, fromPromise, of } from 'hyper-async'
import { isNotNil, prop } from 'ramda'

import { loadProcessMetaSchema, locateSchedulerSchema } from '../../dal.js'
import { eqOrIncludes, parseTags } from '../utils.js'
import { eqOrIncludes, parseTags, trimSlash } from '../utils.js'

/**
* @typedef Env5
Expand All @@ -25,7 +25,7 @@ function verifyProcessTagsWith ({ loadProcessMeta, locateScheduler }) {
return (id) => {
return of(id)
.chain(locateScheduler)
.chain(({ url }) => loadProcessMeta({ suUrl: url, processId: id }))
.chain(({ url }) => loadProcessMeta({ suUrl: trimSlash(url), processId: id }))
.map(prop('tags'))
.map(parseTags)
.chain(checkTag('Data-Protocol', eqOrIncludes('ao'), 'value \'ao\' was not found on process'))
Expand Down
5 changes: 5 additions & 0 deletions sdk/src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ export function eqOrIncludes (val) {
])
}

export function trimSlash (str = '') {
if (!str.endsWith('/')) return str
return trimSlash(str.slice(0, -1))
}

export function errFrom (err) {
err = err || { message: 'An error occurred' }

Expand Down

0 comments on commit 8cf6ae2

Please sign in to comment.