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

implements req.getPathName() #3298

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tlaloc911
Copy link
Contributor

@tlaloc911 tlaloc911 commented Oct 14, 2024

Description

implements function req.getPathName() in GUI and CLI

image

Resolves #2480, #1874, #987, #3195

GUI
image

CLI

$ node ~/dev/bruno/packages/bruno-cli/bin/bru.js run f2/subgoogle.bru 
Running Request 

f2/subgoogle (200 OK) - 372 ms
** PostResponse script **
Execution Mode:cli
Pathname:/home/tom/Documentos/test/Test/f2/subgoogle.bru
** PostResponse script  END **
   ✓ HTTP OK

Requests:    1 passed, 1 total
Tests:       1 passed, 1 total
Assertions:  0 passed, 0 total

Contribution Checklist:

  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

@tlaloc911 tlaloc911 changed the title implement req.getPathName() implements req.getPathName() Oct 14, 2024
@tlaloc911 tlaloc911 mentioned this pull request Oct 14, 2024
5 tasks
@nikischin
Copy link
Contributor

Great PR, however I personally feel the chosen name is quite confusing. I would rather expect to get the current path part of the Request URL than the script location. Maybe we could rename it to something more clear. All the related Feature Requests suggested different names, maybe we take one of those or any other.

@varunvora
Copy link

Replying to @nikischin

Great PR, however I personally feel the chosen name is quite confusing

I agree

I would rather expect to get the current path part of the Request URL than the script location.

Using a part of the request URL may be complicated. Some APIs use path parameters in the request URL, some have query parameters and some may have special characters. req.url should be good if a script requires the request URL.

I would prefer if the meta object in the bruno request was exposed. That would give the request name with req.meta.name.

@tlaloc911
Copy link
Contributor Author

tlaloc911 commented Nov 22, 2024

Thanks for your feedback @nikischin, @varunvora

For my use case I ended up triming the result of req.getPathName() in script to get relative path + bru name. I think this function could be splitted in two:

req.getRelativePath() ==> Relative path + filename.bru
req.getName() ==> request name wuthout 'bru' extension

base Path is already in:

bru.cwd()

About include them as properties insted of methods I have no preference but previous approved PRs added methods, so I think it is more probable to get this merge as methods.

What do you think?

@nikischin
Copy link
Contributor

I personally don't have any opinion on the implementation, as I did not have the need for this feature yet. However, I guess this is a valuable feature, so I would support it being implemented. I was just trying to recommend renaming it to something more precise.

With getPathName() is it not clear what path is meant. Do we mean the path part of the request URL or the file location path? In this case the second one but honestly, the first one was the first thing for me to come in mind.

That's why I was recommending to rename it, maybe we could use getFilePath() or something to make clear it does not return the request URL.

@varunvora
Copy link

@tlaloc911 thanks for your proposal!
I like req.getName() and req.getRelativePath() 👍

@tlaloc911
Copy link
Contributor Author

hi @helloanoop , what do you thing about this?, your feedback is appreciated

@helloanoop helloanoop self-assigned this Jan 13, 2025
@lohxt1
Copy link
Collaborator

lohxt1 commented Jan 16, 2025

@tlaloc911 i'm working on a pr to add req.getName(), bru.getCollectionName() functions. i am thinking of using the below internal var names, prefixed with __bruno__

i just wanted to check if you would be okay with updating the pr if you agree with this pattern

request.__bruno__requestName
request.__bruno__collectionName

cc: @helloanoop

@helloanoop
Copy link
Contributor

@tlaloc911 @nikischin I created a proposal to discuss the API in depth - See #3817

@lohit-bruno I am fairly confident with the req.getName(), req.getFolderName(), req.getCollectionName(). Please proceed with implementation for the same in a separate PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] New bru.scriptpath with path to .bru file in addition to bru.cwd
6 participants