Skip to content

fix: add slash separator in buildUrl for legacy id option (fixes #163)#164

Open
roomote-v0[bot] wants to merge 5 commits intomainlinefrom
fix/issue-163-malformed-url-with-id-option
Open

fix: add slash separator in buildUrl for legacy id option (fixes #163)#164
roomote-v0[bot] wants to merge 5 commits intomainlinefrom
fix/issue-163-malformed-url-with-id-option

Conversation

@roomote-v0
Copy link
Copy Markdown

@roomote-v0 roomote-v0 bot commented Apr 6, 2026

This PR attempts to address Issue #163 by adding a slash separator in the buildUrl function when using the legacy { id: ... } option.

Changes

  • Modified lib/utils/httpRequestor.js to add / separator between options.url and options.id
  • Added regression test in test/functional/sheets.spec.ts to verify legacy { id: ... } syntax works correctly

Background

In v4.7.2, trailing slashes were removed from API URLs, but the buildUrl function had a fallback path that concatenated options.url + options.id without a slash separator. This caused malformed URLs like sheets{sheetid} instead of sheets/{sheetid} for code using the legacy { id: sheetId } syntax.

Solution

This fix maintains backward compatibility with code using the legacy { id: sheetId } syntax while preserving the v4.7.2 API URL structure without trailing slashes.

Feedback and guidance are welcome!

@roomote-v0
Copy link
Copy Markdown
Author

roomote-v0 bot commented Apr 6, 2026

Rooviewer Clock   See task

Review completed. 2 issues were resolved in this commit.

  • Fix double slash issue in buildUrl when url has trailing slash
  • Update test to verify actual URL construction
  • Fix typo in comment ("Thsi" should be "This")
  • Fix indentation inconsistency
  • Remove duplicate test case for removeSheetFromFavorites
Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@ggoranov-smar ggoranov-smar marked this pull request as ready for review April 6, 2026 14:45
const baseUrl = options.baseUrl || process.env.SMARTSHEET_API_HOST || 'https://api.smartsheet.com/2.0/';
if (options.id) {
return baseUrl + options.url + options.id;
return baseUrl + options.url + '/' + options.id;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we have to check if options.url is undefined too? I can imagine us ending with url like https://api.smartsheet.com/2.0/undefined/123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants