Code Monkey home page Code Monkey logo

Comments (3)

elrido avatar elrido commented on June 12, 2024 1

It provides the path to the API endpoint on the same domain. It will only prepend the URL base to the webservers request URI:

$result['url'] = $this->_urlBase . '?' . $message;

$this->_urlBase = $this->_request->getRequestUri();

PrivateBin/lib/Request.php

Lines 225 to 229 in ec02afc

public function getRequestUri()
{
$uri = array_key_exists('REQUEST_URI', $_SERVER) ? filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL) : '';
return empty($uri) ? '/' : $uri;
}

In the example setup (privatebin.net) the API endpoint is at / and PHP's JSON serializer chooses to be a bit more strict and escapes the slash (see JSON spec, search for "escape"), hence the url getting encoded as \/?[id].

from privatebin.

nain-F49FF806 avatar nain-F49FF806 commented on June 12, 2024

Is this perhaps for a case where the post API endpoint is different from the get API endpoint?

If not, doesn't the paste poster already know the path of the API endpoint when they are making the post request?
Given the API endpoint (1) (known while making post) and this API (2) I don't see how this URL property adds any new information. The client can construct the full url from those pieces (1,2) of info already. Am I missing something?

Also, when making comments, the "url" returned is currently misleading, yes? Because going to that url doesn't really give back the comment.

from privatebin.

elrido avatar elrido commented on June 12, 2024

The API endpoint is always the same (including for human visitors - the only difference is the non-default, server side yourls-proxy). The difference lies in the different payloads and HTTP request types.

from privatebin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.