question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Negate opening slash in url

See original GitHub issue

How to negate opening slash in generated params of custom instance? from

url: `/some-service/v1/some/event/`,

to

url: `some-service/v1/some/event/`,

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
anymaniaxcommented, May 14, 2022

Hello @yyynnn, it’s currently automatically added and there is no way to not have it. You can remove it yourself if needed. But I am curious why would you need that?

0reactions
Ojisamacommented, Aug 29, 2022

Thanks for the quick reply ! If I can be of any help don’t hesitate asking.

For those who stumble across this issue and would like a quick hack to make it work in the meantime, here’s my dodgy Interceptor :

import { Injectable } from '@angular/core';
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { Observable } from 'rxjs';

const isURLFromOrvalGeneratedClient = (url: string): boolean => url.startsWith("/https://");

@Injectable()
export class OrvalLeadingSlashInterceptor implements HttpInterceptor {

  removeLeadingSlash(request: HttpRequest<{}>): HttpRequest<{}> {
    return request.clone({ url: request.url.slice(1) });
  }

  intercept(request: HttpRequest<{}>, next: HttpHandler): Observable<HttpEvent<{}>> {
    if (isURLFromOrvalGeneratedClient(request.url)) {
      return next.handle(this.removeLeadingSlash(request));
    }

    return next.handle(request);
  }
}

Read more comments on GitHub >

github_iconTop Results From Across the Web

OK to skip slash before query string? - Stack Overflow
As a matter of modern spec, yes, it is permissible to skip the slash, contrary to what the accepted answer here claims.
Read more >
To slash or not to slash | Google Search Central Blog
Different content on slash and non-slash URLs is okay for Google, ... Historically, it's common for URLs with a trailing slash to indicate...
Read more >
Trailing slashes in website | Optimizely Developer Community
e.g. a trailing slash in one URL could be read by search engines as two separate and different URLs. This can create the...
Read more >
add trailing slash but still respons without - API Questions
The solution would be to add a 301 redirect, if the trailing slash is missing. But why do Umbraco not work that way...
Read more >
What Is a Trailing Slash in URL & How Does It Affect SEO?
It's ok to have trailing slashes after the domain name; Trailing slash matters for most URLs; Trailing slashes on hostnames don't actually ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found